ant error JAVA_HOME does not point to SDK
I am trying to install SOLR and running "ant example" T开发者_如何转开发he 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"
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/
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/
That does not fix it either.
OK, I was able to solve the problem I was having. I had set JAVA_HOME, but not as a system environment variable.
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
This showed the location ant was looking for java by default, and proved that my variable wasn't being picked up.
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.
Hope this helps someone.
精彩评论