A few days ago I was setting my development environment up and it involved executing some Apache Ant tasks. I had installed latest Java 7, jdk1.7.0_80 to be exact and Ant 1.8.4, required by the project.

Attempted to compile it and got this output:

Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jdk1.7.0_80\lib\tools.jar


C:\Users\......\build.xml:xxx: The following error occurred while executing this line: .......:
The following error occurred while executing .......: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files\Java\jdk1.7.0_80"

The first line logged by Apache Ant hints tools.jar is missing. The most common cause for this error is to have forgotten to install Java Development Kit (JDK) and/or have JAVA_HOME pointing to an actual Java Runtime Environment (JRE) installation instead of a JDK one, JRE doesn’t ship with tools.jar, but as it can be observed, the last line of previous output states JAVA_HOME is set to "C:\Program Files\Java\jdk1.7.0_80".

The problem seems to be that JDK 1.7.0_80 removed tools.jar from JAVA_HOME/lib, the solution to this issue was to install JDK 1.7.0_76 and update JAVA_HOME accordingly.

Thanks for reading and as always, feedback is very much appreciated. If you found this post helpful and would like to receive updates when content like this gets published, sign up to the newsletter.