ant错误JAVA_HOME未指向SDK

ant错误JAVA_HOME未指向SDK,ant,java-home,Ant,Java Home,我正在尝试安装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

我正在尝试安装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_主页(见下文)

然而,当我运行ant时,JAVA_主页显示为 /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_放在家里,因为在其他一些帖子中说这可能会解决这个问题

# echo $ANT_HOME
/usr/share/ant/

这也不能解决问题。

好的,我能够解决我遇到的问题。我已经将JAVA_设置为HOME,但不是作为系统环境变量

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

What does java.home show if you run: ant -diagnostics | grep java.home
这表明ant在默认情况下寻找java的位置,并证明我的变量没有被拾取

我连接的机器正在运行bash,因此我必须将下面的行放入.bash_配置文件中:

JAVA_HOME=/usr/java/jdk1.6.0_18
export JAVA_HOME
在这之后,它顺利运行


希望这对其他人有所帮助。

如果运行:ant-diagnostics | grep java.home,java.home会显示什么?您应该在问题中添加一个linux元标记。我有一个确切的问题。你能解决它吗?
JAVA_HOME=/usr/java/jdk1.6.0_18
export JAVA_HOME