1

我正在尝试安装 SOLR 并运行“ant example”构建变得相当远但随后出现错误:

/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/

但是,当我运行 ant 时,JAVA_HOME 显示为 /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre 而不是 # echo $JAVA_HOME /usr/lib/jvm/java-1.6.0 -openjdk-1.6.0.0.x86_64/ 。我无法弄清楚这是在哪里设置的。我还设置了 ANT_HOME,正如其他一些帖子中所说的那样,这可能会解决问题。

# echo $ANT_HOME
/usr/share/ant/

那也不能解决问题。

4

1 回答 1

3

好的,我能够解决我遇到的问题。我设置了 JAVA_HOME,但没有设置为系统环境变量。

基本上,ant 正在生成一个新进程,并且没有拾取我设置的任何 shell 变量。因此,虽然我当前的 shell 可以看到 $JAVA_HOME,但在 ant 运行时却不能。这是布赖恩凯利对以下问题的有益评论:

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

这表明位置 ant 默认情况下正在寻找 java,并证明我的变量没有被拾取。

我连接的机器正在运行 bash,所以我必须将下面的行放入 .bash_profile:

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

在此之后,它顺利运行。

希望这可以帮助某人。

于 2011-11-08T17:42:03.547 回答