Maven Project on Eclipse revert java compiler version (from 1.8 to 1.5) after update (alt f5)

1.8k views Asked by At

as mentioned in the title I have this problem: if I try to edit the compiler version of my Maven Project (by right click on the proj -> Preferences -> Compiler...apply,ok ), after I press alt-f5 (update) i loose all the previous settings and if i re-enter preferences menu i find the java compiler back to 1.5 (always JDK 8 , but 1.5 instead of 1.8).

I tried many ways and combinations, e.g. setting compiler by Preferences -> Facet , or adding maven plugin to my pom, i really can't find a working solution.

Note that in my global preferences Java Runtime Enviroment is correctly set to JDK 8 1.8.

Anyone could help me? Thanks in advance,

Giulio

1

There are 1 answers

0
E-Riz On

The Maven integration plugins for Eclipse (m2e) is pretty aggressive about updating your Eclipse project settings based on the contents of the pom. I wish it didn't do that, because it's not as good at configuring Eclipse settings as it should be.

In any case, you can specify the Java version you want in the pom (via the maven-compiler-plugin configuration), and it should be reflected automatically in the Eclipse project settings. For example:

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

For more details about making sure this results in the project pointing to the correct JRE, see https://stackoverflow.com/a/33126005/639520