I’m writing this in my blog so it will get Googled. I tried searching for a solution to this problem and came up empty.

If you are using the Ant Eclipse plug-in and get the following error message

[javac] BUILD FAILED: file:C:/[ECLIPSE_DIR]/workspace/[PROJECT_DIR]/build.xml:32: Unable to find a javac compiler; is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK

you are using the wrong Java Virtual Machine (JVM) with Eclipse. Ant goes ahead and uses the javac from the JVM Eclipse is using no matter what you put in the compiler attribute. This is bad because Eclipse uses the first Java VM it finds on your computer’s PATH variable.

In my case I installed the Java Runtime Environment (JRE) before the Java Software Development Kit (SDK) and Eclipse was using the JRE by default. Ant doesn’t work with the JRE.

So you have to tell Eclipse to run using the SDK so that Ant can use the SDK. To do this make a shortcut to eclipse.exe and change the target to:

[ECLIPSE_DIR]\eclipse.exe -vm [SDK_DIR]\bin\javaw.exe

Where [ECLIPSE_DIR] and [SDK_DIR] are the full paths to the Eclipse and Java SDK directories respectively.