Ant error when trying to build file, can't find tools.jar?

Derek picture Derek · Apr 11, 2010 · Viewed 102.1k times · Source

When I run ant it says:

Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
Buildfile: build.xml does not exist!
Build failed

What package can I use to download the file required > C:\Program Files\Java\jre6\lib\tools.jar

I just downloaded this one:

jre-6u19-windows-i586-s.exe

but unfortunately it appears that it was not on it...

Answer

jayshao picture jayshao · Apr 11, 2010

Java ships in 2 versions: JRE & SDK (used to be called JDK)

The JRE in addition to not containing the compiler, also doesn't contain all of the libraries available in the JDK (tools.jar is one of them)

When you download Java at: http://java.sun.com/javase/downloads/index.jsp, make sure to select the JDK version and install it. If you have both a JDK & JRE, make sure that ANT is using the JDK, you can check JAVA_HOME (environment variable), and on the commandline if you do "javac -version" you should get a version description.