New Maven projects created in Eclipse (on Windows) use the default JRE System Library "J2SE-1.5".
Default System Library in Maven Project
The project was created the following way:
I want to use the JDK 1.8.0, which is my default JDK for non Maven projects.
My JAVA_HOME variable is set to
C:\Program Files\Java\jdk1.8.0_152
I tried switching the system library via Right Click on the System Library and set the path to my JDK 1.8.0. But after a Maven update it resets back to the 1.5.
Other Stackoverflow questions just suggest to set the JAVA_HOME, but that did not work for me. Specify JDK for Maven to use
I looked for some POM.xml commands to set the library, but couldn't find anything. My POM looks pretty standard right now:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>Test123</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Test123</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
What do I need to change to get the JDK 1.8 as my default Library?
Set the JDK in the pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
in eclipse do a 'Maven->Update Project'
Open your Eclipse, click on
Windows -> Preferences -> Java -> Installed JREs
Verify that the checked JRE refers to the JDK you want. Otherwise, select the checked JRE and click Edit, and change the path to the JDK home.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With