I am building a project in Java.
I have this error:
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
I have installed a JDK and the folder: C:\Program Files\Java\jre6\lib
is in my system but the file tools.jar
is not there.
I had the same problem and copying
C:\Program Files\Java\jdk1.6.0_26\lib\tools.jar
toC:\Program Files\Java\jre6\lib\ext
worked for memaven-compiler-plugin use jdk ,not jre, tools.jar is in C:\Program Files\Java\jdk1.6.0\lib\tools.jar you must config project JRE System Libary with jdk,not jar. This is the simplest solution.
I had the same issue on a linux machine. I was quite frustrated at first, because I have installed both the JDK and JRE. I am using version 1.6, 1.7 and 1.8 simultaneously, and I have played a lot with the alternatives to have everything set properly.
The problem was quite stupid to solve, yet counter-intuitive. While I was using the correct JDK, I paid attention to the path of the tools jar maven complained about - it was expecting it to be
The
$JAVA_HOME
variable pointed directly to myjdk
folder (/usr/local/java
which was also the correct$PATH
entry and alternative sym link). It actually searches for thelib
folder outside the java directory, because:will resolve to
and that is not a valid location.
To solve this, the
$JAVA_HOME
variable should instead point to this location/usr/local/java/jre
(assuming the JDK path is/usr/local/java
) -- there is actuallyjre
folder inside the JDK installation directory, that comes with each JDK. This new setup will cause maven to look at the JRE directory, that is part of the JDK:which now resolves to
and finally to
which is where the
tools.jar
really resides.So, even of you are indeed using the JDK instead of the JRE, the $JAVA_HOME has to point to the JRE. Remember, the OS alternative should still refer to the JDK.
I had my JDK_path (
C:\Program Files\Java\jdk1.7.0_79
) in myJAVA_HOME
and also the JDK_path\bin in myPATH
. But, still my ant was using the JRE instead of JDK.The issue was I had
C:\ProgramData\Oracle\Java\javapath
before my JDK_path inPATH
variable. I simply moved my JDK_path before the oracle one and the issue solved.solving this problem I have simply copied the tools.jar file from C:\Program Files\Java\jre1.8.0_112\lib to C:\Program Files\Java\jdk1.8.0_112\lib so that I have two tools.jar files instead of one and problem disappeared.
Yes, you've downloaded and installed the Java Runtime Environment (JRE) instead of the Java Development Kit (JDK). The latter has the tools.jar, java.exe, javac.exe, etc.