Maven in Eclipse complains that “Unable to locate the Javac Compiler” whenever POM changed

后端 未结 12 774
后悔当初
后悔当初 2020-12-05 07:25

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

Build errors for myapp; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to ex         


        
相关标签:
12条回答
  • 2020-12-05 07:56

    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.

    0 讨论(0)
  • 2020-12-05 08:00

    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.

    0 讨论(0)
  • 2020-12-05 08:04

    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
    0 讨论(0)
  • 2020-12-05 08:10

    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.

    0 讨论(0)
  • 2020-12-05 08:11

    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".

    0 讨论(0)
  • 2020-12-05 08:11

    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.

    0 讨论(0)
提交回复
热议问题