2
votes

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.

4

4 Answers

2
votes

I was also facing same issue but after research of an 1 hour I got a solution.

  1. In system variable set your jdk path in starting.
  2. Variable name: Path
  3. Variable value: C:\ProgramFiles\Java\jdk1.8.0_45\bin;C:\Users\SESA401780\AppData\Local\Android\sdk\build-tools;C:\Users\SESA401780\AppData\Local\Android\sdk\tools;...

  4. Enter Ok Ok ... and

  5. Open new cmd
3
votes

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.

1
votes

You are most likely missing the JAVA_HOME environment variable. It looks like the java.exe you are running from the command line is finding your JRE, not your JDK. Set JAVA_HOME to the location of your JDK, and move the bin directory of your JDK to be before the JRE in your PATH and try again, should work.

0
votes

As the error message says:

Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.
0_25\lib\tools.jar

tools.jar is expected to be in C:\Program Files\Java\jre1.8, but it's not there. That path looks suspiciously like a JRE path, not a JDK.

Make sure to set JAVA_HOME to the path of your JDK. Then it should work. It seems that currently JAVA_HOME is pointing to the path of the JRE, not the JDK.