Why is maven ignoring my JAVA_HOME?

This is what I get when mvnexecuted 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 from the command line gives the correct result. Why mvnis included in this tools.jar? Why is he ignoring mine JAVA_HOME? And how can I fix this?

I do not know what the values JAVA_HOME/PATHare when mvnstarting from CC. I would really like to receive this information, but I do not know how to do it. CC itself starts from the user ccand envif this user gives me (this is CentOS 5.4):

JAVA_HOME=/usr/java/default
PATH=/usr/local/maven/bin:/usr/local/bin:/bin:/usr/bin:/home/cc/bin
+3
source share
6 answers

Suppose you have a Linux machine.

  • Take a look at /usr/bin/java, this is a symbolic link. See where the target of this symbolic link is located (in my case, the target is in this place /etc/alternatives/java)
  • /etc/alternatives/javaalso a symbolic link. Create a new symlink to the "correct" JVM (for example, Sun JVM)
  • Replace /etc/alternatives/javawith a new symbolic link.

Ubuntu. , , : D

+1

, Java JDK :

apt-get install openjdk-6-jdk

+11

mvn tools.jar?

tools.jar com.sun.tools.javac.Main, javac.

JAVA_HOME

"" ( CC). CC ? , JAVA_HOME ?

echo $JAVA_HOME -or-
echo $PATH
+2

Sun

sudo update-java-alternatives -s java-6-sun
0

Oracle Java 7 Ubuntu. Gradle (1.6), , . /opt/ gradle/gradle-1.6/bin/gradle JAVA_HOME /usr/lib/jvm/java -7-oracle script. .

0

, , . , : "fork = 'yes" "javac". , javac JAVA_HOME.

0

Source: https://habr.com/ru/post/1756874/


All Articles