Java – Installing ANT – unable to locate tools.jar

antjava

I am trying to install Apache Ant on my system, while setting the path variable. I have jdk installed on my system. I set the ANT_HOME environment variable to where ant is located on the system, i.e, F:\apache-ant-1.9.6\, and the path variable to F:\apache-ant-1.9.6\bin.

path variable
ANT_HOME variable

But when I test if ANT is installed correctly by typing ant -version on cmd , I get this error:

Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.
0_25\lib\tools.jar
Apache Ant(TM) version 1.9.6 compiled on June 29 2015

While reading this answer, they say tools.jar in included in jdk and not jre. But I have correctly installed jdk, and set the environment variable correctly for that too.

Best Answer

When you actually go to the location specified by ant build it'll not have tools.jar. The error is misleading and wrong. It is just because either JAVA_HOME is not defined or not set properly. Once it is done, error would get resolved.

Related Topic