Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant "JAVA_HOME does not point to the JDK" - but it does

Tags:

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?

like image 945
Morten Grum Avatar asked Feb 26 '13 20:02

Morten Grum


People also ask

Should JAVA_HOME point to JDK?

If you're doing any sort of development, or building with Maven or Ant, you need to point to the JDK (Java Development Kit) where utilities such as javac (the Java Compiler) reside. Otherwise, you can point to the JRE (Java Runtime Environment). The JDK contains everything the JRE has and more.

Where is JAVA_HOME supposed to point?

To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1. 6.0_02.

What happens if JAVA_HOME is not set?

If any program that requires a Java runtime fails to find the JAVA_HOME environment variable upon startup, or if the JAVA_HOME environment variable is misconfigured, it will result in some of the following error messages to be displayed: A Java installation exists but JAVA_HOME has been set incorrectly.

Where is JAVA_HOME for OpenJDK?

Type the variable name "JAVA_HOME" and at variable value the default installation path of the Java Virtual Machine or OpenJDK. The default folder is C:\Program Files\Java\[version]


1 Answers

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

like image 145
viniciussss Avatar answered Sep 20 '22 15:09

viniciussss