What are the details of your problem?
Why does Eclipse's Maven's plug-in overwrite the Java version set with a lower version?
When the Eclipse Maven-plugin runs Project Update...
, the JDK gets switched from 11 to 8.
This causes Java version 11+ stuff in the code to break and unable to compile or run.
When I try to switch the project back to 11+ and compile, the Maven dependency imports break.
To get the Maven packaged packages from Nexus, I end up running Project Update
to resolve.
This causes Eclipse-Maven to set the JDK to 8. The project needs Java-11 or higher.
What needs to happen to allow the Maven dependencies to resolve and the correct Java version be used?
Environment Versions:
- Eclipse: 2023-06 (4.28.0)
- Java-8: 1.8.0_301
- Java-11: 11.0.15.1
- Maven: 3.9.1/3.9.100.20230519-1558 (EMBEDDED)
- OS: Windows 10
What did you try and what were you expecting?
- Running Maven
mvn compile
,mvn install
,mvn package
,mvn clean compile
and any other combinations anyways- Result: Maven Build Failed
- Changing the Eclipse-Project-Properties:
Java Build Path
,Java Code Style
,Java Compiler
; to be JDK-11-
Editing the JRE-Selection with its
System library
selection:Execution environment
,Alternate JRE
, andWorkspace default JRE
(which I set with the Eclipse-Preferences)- Result: Maps, Lists, and other Java imports break
Removing and Readding the
JRE System Library
- Result: Maps, Lists, and other Java imports break
Checkbox-Selecting in
Order and Export
forMaven Dependencies
andJRE System Library
- Result: Nothing notable to the situation changed
-
Enabling and Disabling explicit
Enable project specific settings
to Java-11- Result: No notable changes
-
Enabling and Disabling explicit
Enable project specific settings
to Java-11- Result: Maps, Lists, and other Java imports break
-
- Adding the POM Java Versions in the
properties.java.version
andproperties.maven.compiler.[source, target]
- Result: No Change
- Setting
JAVA_HOME
is jdk-11- Result: no change (correct location)
- Reverting back the Eclipse-Maven changes in
.classpath
XML for itsclasspath.classpathentry
for theorg.eclipse.jdt.launching
to be<attribute name="maven.pomderived" value="true"/>
and no reference toJavaSE-1.8
- Result: Eclipse-Maven reverts this back
- Editing
org.eclipse.jdt.core.prefs
to explicitly be Java 11 and/or remove references to "1.8"- Result: Eclipse-Maven reverts this back
- Checking Oomph wasn't setting the Java version in
org.eclipse.oomph.setup/setup/user.setup
- Result: No reference to Java or its versions