Search code examples
javaeclipsemavenm2e

Maven (m2e) does not update the JRE in Eclipse


In my pom.xml I declared the Maven compiler plugin as followed:

<plugin>
    <inherited>true</inherited>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.5.1</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <encoding>UTF-8</encoding>
        <showWarnings>true</showWarnings>
        <showDeprecation>true</showDeprecation>
    </configuration>
</plugin>

But m2e does not update the JRE that is used for this project. It still uses Java 1.4. Installed is the JDK 8 update 5. This is the only version that is installed. I am on windows.

Did I miss something? On my Mac I have the same settings and there it works.

Update

I set up a new virtual Windows machine on my Mac and did clean installs of Java 8, Eclipse Kepler SR2 and Maven. Now Maven sets the correct JRE, but Eclipse gives me errors like "Syntax error, X is only available if source level is 1.5 or greater". Project specific settings for the compiler are enabled by m2e and set to 1.7. I also bumped the compiler plugin version to 3.1. I am totally confused. Please help me!


Solution

  • You need to install Java 8 support for Eclipse and Maven via the Eclipse marketplace:

    Help > Eclipse Marketplace > Search for "java 8"
    

    Then install the following two plugins:

    • Java 8 support for Eclipse Kepler SR2
    • Java 8 support for m2e for Eclipse Kepler SR2

    You need to restart Eclipse during the installation.