我試圖運行Ant構建生成一個罐子,我得到以下錯誤:Ant構建 - JAVA_HOME變量不會得到更新
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.91-0.b14.el7_2.x86_64/lib/tools.jar
Buildfile: /my/path/to/the/required.xml
make:
[javac] /my/path/to/the/required..xml:11: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
BUILD FAILED
/my/path/to/the/required.xml:11: 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-1.8.0-openjdk- 1.8.0.91-0.b14.el7_2.x86_64/jre"
我的問題:1。 我做了一些在線閱讀並且我得出結論,因爲我將它指向JRE,而不是JDK,因此它失敗了。起初,我沒有
export JAVA_HOME=readlink -f $(which java)
所以我更新,並遠銷我的JAVA_HOME變量,which javac
命令的輸出。有趣的是,錯誤的最後部分沒有顯示更改的JAVA_HOME值。這是爲什麼?
- 這是什麼
includeantruntime
以及如何擺脫它?我使用ant 1.9.2
你是否在同一個用戶的同一個shell中運行了ant任務,你之前已將JAVA_HOME設置爲JDK?如果不是你的錯。在shell中設置一個env var,它不是持久的,並且不會在其他shell會話之間共享! –
他們在Redhat Linux 6上運行在相同的shell和相同的用戶帳戶,我使用bash shell。所以,這兩個命令的環境變量應該是共同的,這就是我的感受。 –