This is what I'm getting when mvn
is executed from CruiseControl:
Unable to locate the Javac Compiler in: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../lib/tools.jar Please ensure you are using JDK 1.4 or above and not a JRE (the com.sun.tools.javac.Main class is required). In most cases you can change the location of your Java installation by setting the JAVA_HOME environment variable.
At the same time, starting it from command line gives correct result. Why mvn
is going into this tools.jar
? Why it is ignoring my JAVA_HOME
? And how can I fix it?
I don't know what are the values of JAVA_HOME/PATH
when mvn
is started from CC. I would really love to get this information but I don't know how. CC itself is started from user cc
and env
for this user gives me (it's CentOS 5.4):
JAVA_HOME=/usr/开发者_如何转开发java/default
PATH=/usr/local/maven/bin:/usr/local/bin:/bin:/usr/bin:/home/cc/bin
I had the same problem and a simple re-install of Java JDK solved it for me:
apt-get install openjdk-6-jdk
Why mvn is going into this tools.jar?
Because tools.jar
contains the com.sun.tools.javac.Main
class which is used to invoke the javac
compiler programmatically.
Why it is ignoring my JAVA_HOME
That's the "interesting" part (since it's working outside CC). Are you running CC with a dedicated user? If yes, is JAVA_HOME
well defined for this user? What is the output of
echo $JAVA_HOME -or-
echo $PATH
Assuming that you have a linux machine.
- Take a look on
/usr/bin/java
, this is a symbolic link. Look where is a target of this symbolic link (in my case the target is at this location/etc/alternatives/java
) /etc/alternatives/java
is symbolic link too. Create new symbolic link to "proper" JVM (e.g. Sun's JVM)- Replace
/etc/alternatives/java
with newly created symbolic link.
This works for Ubuntu distribution. There is an automatic way how to do that but I forgot it actually :D
type the following line to the version of Sun
sudo update-java-alternatives -s java-6-sun
I ended up having to point to the Oracle Java 7 installations on Ubuntu. Gradle (1.6) does not seem to like sym links at all. So I edited the /opt/gradle/gradle-1.6/bin/gradle file to export a JAVA_HOME of /usr/lib/jvm/java-7-oracle at the top of the script. It's happy now.
I know this is far outdated question, but I ended up there googling the same problem. So this solution also works fine: just put "fork='yes'" in "javac" task. After this javac task become honoring the JAVA_HOME setting.
精彩评论