0

For some reason maven automatically chooses java compiler 1.5 when building my project although I have jdk 1.8 installed

Step 1

Project -> Properties -> Java Build Path -> JRE System Library -> Edit, and then choose "Workspace default JRE (jdk1.8.0_102)".

Step 2

Just in case I also set Eclipse -> Preferences -> Installed JREs -> JavaSE-1.8 (jdk.1.8.0_102)

What I noticed in that window: There is only J2SE-1.x where x<=5

Step 3

Then I go to `Project -> Java Compiler, where I find the compiler compliance level set to 1.5 (see screenshot). So I change "Compiler compliance level to 1.8"

java compiler settings in eclipse

When I do maven update, everything is reset to compiler compliance 1.5. If I do a mvn clean compile I also get a build failure that source is 1.5 and some of my code is not compatible.

Thanks for the help

tenticon
  • 2,639
  • 4
  • 32
  • 76

1 Answers1

2

Add this in your pom.xml file under <plugins>:

      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
      </plugin>
Gal Shaboodi
  • 744
  • 1
  • 7
  • 25