2011-06-08 63 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 

在此之后,它跑顺利。

希望这可以帮助别人。