Java – Ant is using the JRE instead of JDK, although the environment variables are set

antapachejava

I am using Windows 7 x64 and I'm trying to install Apache Ant. I'm always get the following error message:

C:\Users\xxx>ant Unable to locate
tools.jar. Expected to find it in
C:\Program Files\Java\jre6\li
b\tools.jar Buildfile: build.xml does
not exist! Build failed

In various forums they say that the environment variables are not set correctly. I set them as following on my system:

ANT_HOME: C:\Ant

CLASSPATH: C:\Program Files\Java\jdk1.6.0_21\bin

JAVA_HOME: C:\Program Files\Java\jdk1.6.0_21\bin

Path: (…many things…);C:\Program Files\Java\jdk1.6.0_21\bin;C:\ant\bin;%JAVA_HOME%\bin;

But I am still getting the error. Do you know how to force ant to use the correct directory? Java (both JRE and JDK) appear in Program Files and Program Files (x86). And seems trying to use the 64x JRE.

Best Answer

JAVA_HOME should be C:\Program Files\Java\jdk1.6.0_21\ (drop the "bin") and tools.jar is going to be in lib, not bin.