蚂蚁错误JAVA_HOME没有指向SDK [英] ant error JAVA_HOME does not point to SDK

查看:29
本文介绍了蚂蚁错误JAVA_HOME没有指向SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装 SOLR 并运行ant 示例"构建过程很远但随后出现错误:

I am trying to install SOLR and running "ant example" The build gets pretty far but then gives an error:

/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(见下文)

I have explicity set JAVA_HOME (see below)

# 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,因为它在其他一些帖子中说明这可能会解决问题.

However the JAVA_HOME when I run ant is showing as /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre instead of # echo $JAVA_HOME /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/ . I cannot figure out where this is being set. I also set ANT_HOME as it was stated in some other posts that this might fix the issue.

# echo $ANT_HOME
/usr/share/ant/

这也不能解决问题.

推荐答案

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

OK, I was able to solve the problem I was having. I had set JAVA_HOME, but not as a system environment variable.

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

Basically, ant was spawning a new process and wasn't picking up any of the shell variables I had set. So while my current shell could see $JAVA_HOME, when ant was running it could not. It was Brian Kelly's helpful comment on the question of:

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

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

This showed the location ant was looking for java by default, and proved that my variable wasn't being picked up.

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

The machine I was connected to was running bash, so I had to put the lines below into .bash_profile:

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

此后,它顺利运行.

希望这对某人有所帮助.

Hope this helps someone.

这篇关于蚂蚁错误JAVA_HOME没有指向SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆