Maven "Build Path Specifies Execution Environment J2Se-1.5", Even Though I Changed It to 1.7

Maven build path specifies execution environment J2SE-1.5, even though I changed it to 1.7

  1. Right-click on your project
  2. Click Properties
  3. Click the "Java Compiler" option on the left menu
  4. Under JDK compliance section on the right, change it to "1.7"
  5. Run a Maven clean and then Maven build.

Warning - Build path specifies execution environment J2SE-1.4

In Eclipse from your project:

  1. Right-click on your project
  2. Click Properties
  3. Java build path: Libraries; Remove the "JRE System Library[J2SE 1.4]"
  4. Click Add Library -> JRE System Library
  5. Select the new "Execution Environment" or Workspace default JRE

Eclipse Warning Build path specifies execution environment JavaSE-17.

Use of Java 18 requires both Eclipse 2022-03 and this patch from the Marketplace. 2022-03 came out a week before Java 18 (March 16th vs. March 22nd), so it can not officially claim to support it. The patch should be uninstalled before updating to 2022-06 later this month.

Java version automatically change to java 1.5 after maven update

Open your pom.xml file and add the following lines on it:

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

Where 1.8 is the Java version of your current JDK/JRE. Another way of doing this is adding a <build> with the maven-compile-plugin as:

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version> <!-- or whatever current version -->
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

If you are looking for a way to make it work with Java versions 9+ please take a look at @JDelorean's answer.



Related Topics



Leave a reply



Submit