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

后端 未结 24 1031
北恋
北恋 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 17:08

    I encountered the same problem when I try to run Ant build using the following command:

    java -cp ant.jar:ant-launcher.jar org.apache.tools.ant.Main
    

    The output of the command is:

    BUILD FAILED
    XXX/build.xml:8: 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 "/usr/lib/jvm/java-6-openjdk/jre"
    

    It seems the java executable is picking "/usr/lib/jvm/java-6-openjdk/jre" as JAVA_HOME, as opposed to "/usr/lib/jvm/java-6-openjdk" where JDK is installed.

    I resolved this issue by setting fork="yes" in my task.

    Take a look at: http://ant.apache.org/manual/Tasks/javac.html

提交回复
热议问题