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

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

问题描述

我试图安装SOLR和运行蚂蚁例如构建得到pretty远,但随后给出了一个错误:

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/

然而,JAVA_HOME,当我运行蚂蚁作为展示
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre代替#回声$ 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/

这没有解决它的。

推荐答案

OK,我能解决我遇到的问题。我已经设置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.

基本上,蚂蚁是产卵新的进程,并没有拿起任何我已经设置shell变量。因此,虽然我目前的外壳可以看到$ JAVA_HOME,当蚂蚁正在运行它不能。这是布莱恩·凯利对问题有帮助的注释:

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

这表明,位置蚂蚁一直在寻找默认的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

在此之后,它跑顺利。

After this, it ran without a hitch.

希望这可以帮助别人。

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

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