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

前端 未结 6 757
终归单人心
终归单人心 2020-12-31 01:23

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 t

相关标签:
6条回答
  • 2020-12-31 01:34

    Try adding JAVA_HOME\bin to your env PATH .

    0 讨论(0)
  • 2020-12-31 01:39

    The real message is that Ant can't find com.sun.tools.javac.Main.

    Which, together with the fact that the latest "Sun" (Oracle) JDK is 1.7.0_13 (or maybe _14, but definitely not the "_52" that your install dir indicates), makes me think that you're not using a distribution that Ant recognizes. You can verify this by running jar tvf $JAVA_HOME/lib/tools.jar, and looking for that class.

    The Ant Manual talks about ways to work with different compilers. Since I've only used "Sun" compilers, I'm afraid that I can't give you any pointers.


    Edit: you could also try setting fork="yes" in your build file. This should run the compiler executable rather than trying to invoke the compiler class.

    0 讨论(0)
  • 2020-12-31 01:44

    The solution "Had to copy C:\Program Files\Java\jdk1.6.0_10\lib\tools.jar to C:\Program Files\Java\jre6\lib\ext" from here was great helpful and worked for me.

    0 讨论(0)
  • 2020-12-31 01:48

    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

    0 讨论(0)
  • 2020-12-31 01:55

    Sorry for the unearthing,

    I had the same problem, my solution doesn't need any modification in environment variables, and works for a recent JDK where the tools.jar can't be found.

    Just go in the small down-arrow next to the ant run button Then click "Configure external tools" Then in JRE tab Select a JDK installed on your computer, not a JRE, no problems if the selected JDK is not the same JDK/JRE as in your project.

    It should be work now.

    0 讨论(0)
  • 2020-12-31 01:57

    Add JAVA_HOME to Eclipse-Preferences-Java-Build Path-Classpath Variables.

    0 讨论(0)
提交回复
热议问题