Maven build path specifies execution environment J2SE-1.5, even though I changed it to 1.7
- Right-click on your project
- Click Properties
- Click the "Java Compiler" option on the left menu
- Under JDK compliance section on the right, change it to "1.7"
- Run a Maven clean and then Maven build.
Warning - Build path specifies execution environment J2SE-1.4
In Eclipse from your project:
- Right-click on your project
- Click Properties
- Java build path: Libraries; Remove the "JRE System Library[J2SE 1.4]"
- Click Add Library -> JRE System Library
- 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
How to Reference a Method in Javadoc
Making a Log4J Console Appender Use Different Colors for Different Threads
Jackson/Hibernate, Meta Get Methods and Serialization
Find Duplicate Element in Array in Time O(N)
Why Is System.Arraycopy Native in Java
How to Determine If a Point Is Inside a 2D Convex Polygon
How to Add Test Coverage to a Private Constructor
How to Serialize Static Data Members of a Java Class
Write a Mode Method in Java to Find the Most Frequently Occurring Element in an Array
How to Solve the "A Generic Array of T Is Created for a Varargs Parameter" Compiler Warning
Can a Class Have No Constructor
Environment Variable with Maven
Java Error: Cannot Make a Static Reference to the Non-Static Method
How to Convert a Binary String to a Base 10 Integer in Java
Does Java Have Any Mechanism for a Vm to Trace Method Calls on Itself, Without Using Javaagent, etc
Waiting at Sun.Misc.Unsafe.Park(Native Method)