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?
The problem is with version of JDK you are using. The Intellij version 2020.2 supports only upto JDK 14. So either you have to lower the JDK version to 14 or update the IntelliJ to a newer version like 2021.
Ant expects the tools. jar file to be in the %JAVA_HOME%/lib but tools. jar is distributed with the JDK.
The jar tool combines multiple files into a single JAR archive file. jar is a general-purpose archiving and compression tool, based on ZIP and the ZLIB compression format. However, jar was designed mainly to facilitate the packaging of java applets or applications into a single archive.
1. rt. jar stands for runtime and contains all of the compiled class files for the core Java Runtime environment. 2) You must include rt. jar in your classpath, otherwise you don't have access to core classes e.g. java.
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)
I was also having the same problem So I just removed the JDK path from the end and put it in start even before all System or Windows 32 paths.
Before it was like this:
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Users\Rajkaran\AppData\Local\Smartbar\Application\;C:\Users\Rajkaran\AppData\Local\Smartbar\Application\;C:\Program Files\doxygen\bin;%JAVA_HOME%\bin;%ANT_HOME%\bin
So I made it like this:
%JAVA_HOME%\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Users\Rajkaran\AppData\Local\Smartbar\Application\;C:\Users\Rajkaran\AppData\Local\Smartbar\Application\;C:\Program Files\doxygen\bin;%ANT_HOME%\bin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With