Java – Ant “JAVA_HOME does not point to the JDK” – but it does

anteclipsejava

I cannot run my Ant build.xml since I updated to java 1.7.0_52 (or there about). I have been running it for years through Eclipse locally on my Windows 7 laptop – but with this latest jave jdk update somethings different (?).

BUILD FAILED
C:\workspace\WaterAspectsModel3\build.xml:329: 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 "D:\Morten\Java\jdk1.7.0_52"

This is my jdk! So JAVA_HOME is pointing to a jdk (as is also clear from the error message). I have my JAVA_HOME with bin folder in my path as always. I've configured Eclipse – external tools configuration – with a JRE pointing to the same D:\Morten\Java\jdk1.7.0_52 (through "Separate JRE" setting). And I've tried a number of other configurations – all without luck.

I've been reading the tonnes of answers on lists here and other places and think I've tried all suggestions. Most seem to be cases where JAVA_HOME actually points to a jre and just needs to be corrected to jdk or there's a ";" in the path or something like that. None of these seem to apply in my case.

Any suggestions?

Best Answer

I was having the same message when running ANT through Eclipse.

What worked for me:

  1. In Eclipse, access the menu: "Window -> Preferences";
  2. Access "Ant -> Runtime", at the tree;
  3. Access the Classpath tab;
  4. Expand the "Global Entries" item;
  5. Inside Global Entries, the path to tools.jar was wrong. It was pointing to an older version of Java;
  6. I removed the wrong entry and added the correct one with "Add External Jars" button. It worked.

enter image description here