2011-06-08 64 views
1

我試圖安裝SOLR和運行「螞蟻例如」構建得到相當遠,但隨後給出了一個錯誤:螞蟻錯誤JAVA_HOME沒有指向SDK

/root/apache-solr-3.2.0/solr/common-build.xml:250: The following error occurred while executing this line: 
/root/apache-solr-3.2.0/lucene/contrib/contrib-build.xml:58: The following error occurred while executing this line: 
/root/apache-solr-3.2.0/lucene/common-build.xml:298: The following error occurred while executing this line: 
/root/apache-solr-3.2.0/lucene/common-build.xml:733: 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.6.0-openjdk-1.6.0.0.x86_64/jre" 

我必須明確地設置JAVA_HOME(見下文)

# echo $JAVA_HOME 
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/ 

然而,當我運行螞蟻顯示爲 /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre代替#的JAVA_HOME回聲$ JAVA_HOME 在/ usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64 /。我無法弄清楚在哪裏設置。我還設置了ANT_HOME,因爲在其他一些帖子中提到這可能會解決問題。

# echo $ANT_HOME 
/usr/share/ant/ 

這並沒有解決它。

+2

如果運行java.home會顯示什麼內容:ant -diagnostics | grep java.home – 2011-06-08 21:18:50

+0

你應該爲你的問題添加一個linux metatag。 – djangofan 2011-10-26 20:00:03

+0

我有這個確切的問題。你能解決它嗎? – Clarkey 2011-11-04 09:55:53

回答

3

好的,我能解決我遇到的問題。我設置了JAVA_HOME,但不是作爲系統環境變量。

基本上,螞蟻產卵了一個新的過程,並沒有拿起我設置的任何shell變量。所以雖然我當前的shell可以看到$ JAVA_HOME,但是當螞蟻運行時它不能。這是布萊恩·凱利對問題有幫助的註釋:

What does java.home show if you run: ant -diagnostics | grep java.home 

這表明位置螞蟻一直在尋找通過默認的Java,並證明了我的變量沒有被拾起。

我連接到正在運行的bash的機器,所以我不得不把線以下,進入的.bash_profile:

JAVA_HOME=/usr/java/jdk1.6.0_18 
export JAVA_HOME 

在此之後,它跑順利。

希望這可以幫助別人。