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

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.


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.


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.


Setting fork to true resolved the issue for me.

<configuration>
    <fork>true</fork>
    <source>1.6</source>
    <target>1.6</target>
</configuration>

I had exact the same problem! I had been searching and searching for days because all the babble about "put the -vm c:\program files\java\jdkxxxxx\bin" in the ini ar as argument for a shortcut did not at all help!

(Do I sound frustrated? Believe me, that's an understatement! I am simply furious because I lost a week trying to make Maven reliable!)

I had very unpredictable behavior. Sometimes it compiled and sometimes not. If I did a maven clean, it could not find the compiler and failed. If I then changed something in the build path, it suddenly worked again!!

Until I went to menu WindowPreferencesJavaInstalled JRE's. I added a new JRE using the location of the JDK and then removed the JRE. Suddenly Maven ran stable!

Maybe this is worth putting in letters with font-size 30 or so in the Apache manual?

With all due respect, this is simply outrageous for the Java community! I can't imagine how many days were lost by all these people, trying to work out their problems of this kind! I cannot possibly imagine this is released as a final version. I personally would not even dare to release such a thing under the name beta software...

Kind regards either way.... After a week of tampering I can finally start developing. I hope my boss won't find out about this. It took me lots of effort to convince him not to go to .NET and I already feel sorry about it.