Why does ANT tell me that JAVA_HOME is wrong when it is not?

后端 未结 24 1029
北恋
北恋 2020-12-07 16:49

I get the error:

C:\\dev\\ws\\springapp\\build.xml:81: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not

24条回答
  •  一个人的身影
    2020-12-07 16:57

    The semicolon was throwing me off: I had JAVA_HOME set to "C:\jdk1.6.0_26;" instead of "C:\jdk1.6.0_26". I removed the trailing semicolon after following Jon Skeet's suggestion to examine the ant.bat file. This is part of that file:

    if "%JAVA_HOME%" == "" goto noJavaHome
    if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
    

    So the semi-colon wasn't being trimmed off the end, causing this to fail to find the file, therefore defaulting to "C:\Java\jre6" or something like that.

    The confusing part is that the HowtoBuild page states to use the semi-colon, but that seems to break it.

提交回复
热议问题