23

I got error message every time I changed my pom.xml in eclipse.

Build errors for myapp; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project web: Compilation failure
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 have set JAVA_HOME environment variable. It is:JAVA_HOME=D:\Java\jdk1.6.0_23

Thanks.

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
Tom
  • 2,857
  • 9
  • 46
  • 59
  • I have the same issue and i am not able to slove by this answer can you please see http://stackoverflow.com/questions/12049566/an-internal-error-occurred-during-enabling-maven-dependency-management-unsup – Hemant Metalia Aug 21 '12 at 07:18

12 Answers12

54

This is the step I did to solve that problem (Eclipse 3.7 Indigo):

Window -> Preferences -> Java -> installed JREs -> I have a JRE from the JDK location, my location looks like C:\Program Files\Java\jdk1.6.0_26

Window -> Preferences -> Java -> installed JREs -> Execution Environments -> Select JavaSE-1.6 and select a compatible JDK which should be the one set in the previous step.

Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
Sydney
  • 11,964
  • 19
  • 90
  • 142
  • I had to add a new "Standard VM" entry in the UI, and specify my JAVA_HOME folder to the JDK for that entry, then I was able to select the check box for the item I had added, as described. – Mazrick Jul 03 '12 at 14:17
  • 2
    If this does not work, doublecheck that the project itself is configured to use the JDK and not the JRE. – BennyMcBenBen Aug 30 '12 at 19:04
  • Window -> Preferences -> Java -> installed JREs -> Execution Environments helped me a lot. – prashant thakre May 11 '15 at 12:43
19

None of the above worked for me but when I followed the following steps, the problem went away.

  • Go to Window -> Preferences -> Java -> installed JREs
  • Select the JRE you are using (Should be the one inside jdk. Ex: C:\Program Files\Java\jdk1.6.0_25\jre)
  • Press Edit -> Add External JARs...
  • Browse to Java\jdk1.6.0_25\lib and select tools.jar and Press Enter
  • Press Finish and OK
Jonas G. Drange
  • 8,749
  • 2
  • 27
  • 38
isuru chathuranga
  • 995
  • 15
  • 24
  • I have the same issue and i am not able to slove by this answer can you please see http://stackoverflow.com/questions/12049566/an-internal-error-occurred-during-enabling-maven-dependency-management-unsup – Hemant Metalia Aug 21 '12 at 07:18
4

This worked for me too :

  1. Go to Window -> Preferences -> Java -> installed JREs
  2. Select the JRE you are using (Should be the one inside jdk. Ex: C:\Program Files\Java\jdk1.6.0_25\jre)
  3. Press Edit -> Add External JARs...
  4. Browse to Java\jdk1.6.0_25\lib and select tools.jar and Press Enter
  5. Press Finish and OK
demongolem
  • 9,474
  • 36
  • 90
  • 105
4

Window -> Preferences -> Java -> installed JREs -> Execution Enviroments -> click the checkbox on the right side

Gambotic
  • 51
  • 2
4

I had this same issue which I just figured out. The Runtime JRE was specified correctly in EVERY other part of eclipse.

I use an eclipse Run Configuration...

The Run Configuration is YET ANOTHER place where the java runtime JRE is specified. If you are using a maven Run Configuration, open that up, click the JRE tab and select the proper (JDK) "Runtime JRE".

april26
  • 833
  • 3
  • 14
  • 27
2

Adding the following two lines at the very beginning of your eclipse.ini file should tell maven where to find JDK:

-vm
C:\Program Files\Java\jdk1.6.0_23\bin\javaw.exe

or whatever path you installed JDK into.

mazaneicha
  • 8,794
  • 4
  • 33
  • 52
  • The command should be ------------ set JAVA_HOME=D:\Java\jdk1.6.0_23 – isobar Mar 02 '11 at 04:01
  • I have the same issue and i am not able to slove by this answer can you please see http://stackoverflow.com/questions/12049566/an-internal-error-occurred-during-enabling-maven-dependency-management-unsup – Hemant Metalia Aug 21 '12 at 07:17
1

I had a similiar issue it got resolved by specifying attributes of the maven-compiler-plugin as below:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
<!-- Need to provide the below properties as the current maven-compiler-plugin version is 2.0.2 and defaults to JDK 1.3 for compiling -->
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>

I had to explicitly specify the source and target attribute. it seems there compilation also depends on the version maven-compiler-plugin and its default JDK setting. Mine was 2.0.2 and its default was JDK 1.3 i gather.

hakish
  • 3,990
  • 7
  • 39
  • 56
1

1.Go to Window -> Preferences -> Java -> installed JREs 2.Select the JRE you are using (Should be the one inside jdk. Ex: C:\Program Files\Java\jdk1.6.0_25\jre) 3.Press Edit -> Add External JARs... 4.Browse to Java\jdk1.6.0_25\lib and select tools.jar and Press Enter 5.Press Finish and OK..

This worked for me.

Nitin
  • 11
  • 3
1

If you are encountering this problem when trying to run maven from eclipse, then you may want to refer to this discussion, which also outlines the solution.

Raghuram
  • 51,854
  • 11
  • 110
  • 122
  • It seems working,but I still got some error:Build errors for myapp; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project web: Compilation failure Failure executing javac, but could not parse the error: – Tom Mar 02 '11 at 07:35
  • 1
    my last comment is stacktrace. – Tom Mar 02 '11 at 09:41
  • I have the same issue and i am not able to slove by this answer can you please see http://stackoverflow.com/questions/12049566/an-internal-error-occurred-during-enabling-maven-dependency-management-unsup – Hemant Metalia Aug 21 '12 at 07:17
1

I had a similar issue; what you should try is performing a mvn install from the POM directory itself, any Maven install you do next in Eclipse itself will work as well afterwards.

levivanzele
  • 726
  • 1
  • 13
  • 33
0

Window -> Preferences -> Java -> installed JREs, add jdk6 to point to your jdk(C:\Program Files\Java\jdk1.6.0_25), delete default jre6. it works.

0

It looks like your JAVA_HOME is not set properly. Can you echo JAVA_HOME from your terminal & see where it is pointing to? From the above error log it looks like its pointing to program files folder.

isobar
  • 1,165
  • 8
  • 10