Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven build failed: "Unable to locate the Javac Compiler in: jre or jdk issue"

I have my JAVA_HOME set to:

C:\Program Files (x86)\Java\jdk1.6.0_18

After I run maven install, I get this message from Eclipse:

Reason:

Unable to locate the Javac Compiler in:
  C:\Program Files (x86)\Java\jre6\..\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'm certain that this is the tricky part

Please ensure you are using JDK 1.4 or above and not a JRE

When I run configuration it's set to JRE6. How do I change it to JDK 1.6 which I have already installed?

I even tried to modify the plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <executable>C:\Program Files (x86)\Java\jdk1.6.0_18\bin</executable>
    </configuration>
</plugin>

Still I get the same error.

I use the Eclipse Maven plugin. How can I change from JRE to JDK in Eclipse?

like image 261
Gandalf StormCrow Avatar asked Feb 08 '10 15:02

Gandalf StormCrow


3 Answers

You could try updating the JDK Eclipse is using, as follows:

Add and set the JRE in menu WindowPreferences...JavaInstalled JREs:

JRE type: Standard VM JRE
Name: jdk1.6.0_18
JRE home directory: C:\Program Files (x86)\Java\jdk1.6.0_18

If this is not the case, it's possible that the brackets and spaces in the JAVA_HOME path are causing issues. Try copying your JDK to a different location and updating your JAVA_HOME.

like image 135
lucrussell Avatar answered Nov 16 '22 19:11

lucrussell


File eclipse.ini needs the vm argument to point to your JDK location.

Edit the eclipse.ini file to point to your JDK home, something as follows -

-vm
C:\Program Files\Java\jdk1.6.0_06

This ensures that Eclipse would be running off the JDK and not any default JRE on your machine.

like image 20
Sai Hegde Avatar answered Nov 16 '22 20:11

Sai Hegde


You try:

Go to Preferences/Java/Installed JREs and add one for the location "C:\Program Files\Java\jdk1.6.0_27\jre or something like that.

Remove the one for C:\Program Files\Java\jre6

As you can see, the path C:\Program Files\Java\jre6\..\lib\tools.jar only makes sense if the first part (til the /..) is replaced by C:\Program Files\Java\jdk1.6.0_27\jre.

like image 13
cuocdoibian1971 Avatar answered Nov 16 '22 21:11

cuocdoibian1971