When running ant, I get the following message:
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
I have JAVA_HOME set to C:\Program Files\Java\jdk1.7.0_02
, PATH includes C:\Program Files (x86)\Java\jdk1.7.0_02\bin
, CLASSPATH includes C:\Program Files (x86)\Java\jdk1.7.0_02
, and ANT_HOME is set to C:\ant
.
It seems that ant is ignoring all of these settings and looking for the tools.jar somewhere else. There are no environment variables which point to the jre6 path. Any ideas why?
There are two directories that looks like JDK.
C:\Program Files\Java\jdk1.7.0_02
C:\Program Files (x86)\Java\jdk1.7.0_02\
This may be due to both 64 bit and 32 bit JDK installed? What ever may be the case, the java.exe
seen by ant.bat should from the JDK. If the JRE's java.exe
comes first in the path, that will be used to guess the JDK location.
Put 'C:\Program Files (x86)\Java\jdk1.7.0_02\bin' or 'C:\Program Files\Java\jdk1.7.0_02' as the first argument in the path.
Further steps:
You can take output of ant -diagnostics
and look for interesting keys. (assuming Sun/Oracle JDK).
java.class.path
java.library.path
sun.boot.library.path
(in my case tools.jar appears in java.class.path)