2015-10-22 135 views
0

我正在Ubuntu上使用Apache Ant構建aprofplot。當我在包含build.xml的文件夾中輸入命令ant時,出現此錯誤:在Ubuntu上使用Ant「無法找到javac編譯器」錯誤

BUILD FAILED 
/home/ashwin/aprof/aprofplot/nbproject/build-impl.xml:923: The following error occurred while executing this line: 
/home/ashwin/aprof/aprofplot/nbproject/build-impl.xml:263: 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-7-openjdk-amd64/jre" 

Total time: 2 seconds 
[email protected]:~/aprof/aprofplot$ javac --version 
The program 'javac' can be found in the following packages: 
* default-jdk 
* ecj 
* gcj-4.8-jdk 
* openjdk-7-jdk 
* gcj-4.6-jdk 
* openjdk-6-jdk 

我也安裝了openjdk。我究竟做錯了什麼?我是否需要安裝更多軟件包?

+0

請參見[如何在Ubuntu上安裝JDK?](http://stackoverflow.com/questions/14788345/how-to-install-jdk-on-ubuntu-linux/14788468# 14788468)。特別是關於'export JAVA_HOME'的說明很重要。 –

+0

我猜想這些庫鏈接不正確。我使用netbeans來運行應用程序。它運行時沒有任何錯誤/構建失敗。 – chrisrhyno2003

回答

0

看來,你錯了JAVA_HOME變量。它指向JRE,從您的輸出:

It is currently set to "/usr/lib/jvm/java-7-openjdk-amd64/jre" 

不是JDK。這就是爲什麼Ant無法找到javac並失敗。你必須修改它。試着在最後刪除jre,看來,javac應該在/usr/lib/jvm/java-7-openjdk-amd64/bin之下。所以你必須將它設置爲/usr/lib/jvm/java-7-openjdk-amd64

相關問題