On ubuntu 11.10, with maven2, here’s the error code:
Unable to locate the Javac Compiler in:
/usr/lib/jvm/java-6-sun-1.6.0.26/../lib/tools.jar
Not sure why it’s adding the “..” in the path?
My tools.jar is at /usr/lib/jvm/java-6-sun-1.6.0.26/lib/tools.jar
I have done:
sudo apt-get install sun-java6*
sudo update-alternatives –config java , and chosen sun-java-6
uncommented the deb-src /etc/apt/sources.list
/home/raymond/.bashrc
JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.26
export JAVA_HOME
~/.profile
JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.26
export JAVA_HOME
/usr/lib/mvn
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "${M2_HOME}"/boot/classworlds.jar \
"-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
"-Dmaven.home=${M2_HOME}" \
"-Djava.home=${JAVA_HOME}" \
${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS
pom.xml, I have this in my builds, plugins
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)
javac -version
javac 1.6.0_26
mvn -version
Apache Maven 2.2.1 (rdebian-6)
Java version: 1.6.0_26
Java home: /usr/lib/jvm/java-6-sun-1.6.0.26
Default locale: en_CA, platform encoding: UTF-8
OS name: "linux" version: "3.0.0-14-generic-pae" arch: "i386" Family: "unix"
It seems I needed to remove this line: “-Djava.home=${JAVA_HOME}” \ from /usr/lib/mvn that I posted in the question. I had added that line following a suggestion from googling. I guess setting the extra java_home had some conflicts.
I think for ubuntu, it’s easier to just install all sun-java6 packages. I only installed -jdk earlier and ran into all sorts of problems trying to get mvn install to work. I think it started to work since I installed everything, I just had a bogus fix in there that prevented it from installing.