Question

I am trying to compile a program using maven in my Linux 12.04. In order to do, I use the mvn clean install command. However I get a build error:

[ERROR] Unable to locate the Javac Compiler in:
  /usr/lib/jvm/java-6-openjdk-amd64/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.

I check the path and indeed I am missing that critical file. This is what I have:

user@modelX:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib$ ls
accessibility.properties  im                    net.properties
amd64                     images                psfontj2d.properties
calendars.properties      jar.binfmt            psfont.properties.ja
charsets.jar              javazic.jar           resources.jar
classlist                 jce.jar               rhino.jar
cmm                       jexec                 rt.jar
compilefontconfig.jar     jsse.jar              security
content-types.properties  jvm.hprof.txt         sound.properties
currency.data             logging.properties    swing.properties
ext                       management            tz.properties
flavormap.properties      management-agent.jar  zi
fontconfig.properties     meta-index

So apparently, I am running openJDK, but I am missing files. How do I fix this?

Was it helpful?

Solution

Apparently I was missing some important packages. I found the solution in this website:

OTHER TIPS

In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

Please make sure that JAVA_HOME points to /usr/lib/jvm/java-6-openjdk-amd64/

Run javac:

  javac

If it is not found, check the PATH:

  echo $PATH

It should contain

  /usr/lib/jvm/java-6-openjdk-amd64/bin

Make sure you have choosen the proper jdk:

$ sudo update-alternatives --config java

I had to choose /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java to run mvn. Ominously, there resides a tools.jar in /usr/lib/jvm/java-7-openjdk-amd64/ , but not in /usr/lib/jvm/java-6-openjdk-amd64/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top