Reputation: 815
So I have my maven project configured to Java9
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.9</source>
<target>1.9</target>
<compilerVersion>1.9</compilerVersion>
</configuration>
</plugin>
</plugins>
</build>
But if I check the project build path it still says JRE System Library [J2SE-1.5] in eclipse (instead of JavaSE-9), so it basically uses Java1.5 and gives me a lot of errors. If I manually correct that entry, everything is fine. But shouldn't Maven handle the complete classpath settings? The answer to this is probabbly quite simple, but I cant figure it out.
Thanks!
EDIT The fix was to remove compilerVersion and edit the source and target tags:
<configuration>
<source>9</source>
<target>9</target>
</configuration>
Upvotes: 0
Views: 560
Reputation: 335
Step 1: Check PATH of MAVEN and JAVA
mvn -v
In the output check if "Java version" is pointing to 1.9
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T13:28:13+05:30)
Maven home: /Maven/3.5.2
Java version: 9.0.4, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-9-oracle
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-119-generic", arch: "amd64", family: "unix"
Step 2: Check JDK 9 is configured in IDE (eclipse / sts)
Step 3: Update your Maven Project for Changes to Take affect
Upvotes: 2
Reputation: 3939
Sometimes the Maven source version (1.9
is your particular case) and the Eclipse source version fall out of sync, especially if the source version in the pom.xml
file is changed after the project has been created in Eclipse. To bring the two back into sync, perform the following:
Maven
Update Project...
You can also update the Maven configuration using Alt + F5. For more information, see What causes imported Maven project in Eclipse to use Java 1.5 instead of Java 1.6 by default and how can I ensure it doesn't?.
Upvotes: 1