Change JDK in Maven Projects (Eclipse)

Java Sep 19, 2018

New Maven projects created in Eclipse use the default JRE System Library "J2SE-1.5". If you want to use a newer version, change your pom.xml like this.

<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>

For Java10:

<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<maven.compiler.source>10</maven.compiler.source>
	<maven.compiler.target>10</maven.compiler.target>
</properties>

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.