tags:

views:

63

answers:

2

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
+1  A: 

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
Pascal Thivent
@Pascal, I just updated my question with the information you asked. Everything works fine outside of CC..
Vincenzo
A: 

Assuming that you have a linux machine.

  1. 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")
  2. "/etc/alternatives/java" is symbolic link too. Create new symbolic link to "proper" JVM (e.g. Sun's JVM)
  3. 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

Vitek
This is the way: `/usr/sbin/alternatives --install /usr/bin/java java /usr/java/latest/bin/java 2`?
Vincenzo