Maven "defines the J2SE-1.5 runtime," although I changed it to 1.7

In Eclipse Juno, I installed the latest m2e plugin (1.2.20120903-1050). In the settings, I added jdk1.7.0_11 to Java -> Installed JREs -> Add, and then specified the location ( C:\Program Files\Java\jdk1.7.0_11 ). When I create a new Maven project and run it, I get a warning:

The build path indicates the J2SE-1.5 runtime. There are no JREs in the workspace that are strictly compatible with this environment.

I am not sure how to resolve this.

I believe this is a Maven problem because I do not have this error when starting regular Java projects. I read here that I have to change the "maven-compiler-plugin.pom" and change the source and target from 1.5 to something more suitable. In my case 1.7. I have done this, but I am still getting a warning.

+51
java eclipse maven m2eclipse
Feb 11 '13 at 2:04
source share
9 answers
  • Right click on your project
  • Click Properties
  • Click "Java Compiler" on the left menu.
  • In the JDK matching section on the right, change it to "1.7"
  • Run Maven clean, and then create Maven.
+36
Feb 11 '13 at 2:31
source share

All of the above answers may work now, but whenever you run maven on the command line or Maven & rightarrow; Update project & hellip; JDK will reset, this is also a question, as I understand it.

To fix this for good, add the following code to your pom file. Remember to make Maven & rightarrow; Update project & hellip; then or mvn clean compile on the command line.

 <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </pluginManagement> </build> 
+100
Nov 15 '13 at 7:55
source share

I know this is an old topic. I have the same problem. I checked all the answers on this topic. And nothing worked here ... but I found another solution.

Go to pom-> overview and add them to the properties:

  • Name: "maven.compiler.target" Value: "1.7"

and

  • Name: "maven.compiler.source" Value: "1.7"

Now do the maven update.

+25
Jun 19 '14 at 9:28
source share

For an imported maven project and JDK 1.7, do the following:

  • Delete project from Eclipse (save files)
  • Delete the .settings, .project and .classpath directory in the project directory.
  • Modify the pom.xml file, add the following properties (make sure the following settings are not overridden by the explicit maven-compiler-plugin definition in your POM)

     <properties> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </properties> 
  • Import the updated project into Eclipse.

+9
Apr 23 '14 at 19:35
source share

I am using Juno 4.2 with the latest spring, maven plugin and JDK1.6.0_25.

I ran into the same problem, and here is my fix that makes it default after every restart of Eclipse:

  • List item
  • Right click maven project
  • Java build path
  • Libraries tab
  • Select current invalid jre item
  • Click "Edit."
  • Select the last option (Default workspace is JRE (jdk1.6.0_25)
+5
Jul 29 '13 at 3:37 on
source share

I ran into the same problem. In pom.xml, I defined a maven compiler plugin to select 1.7 as the source and target. Even when I imported the git project into eclipse, it would choose 1.5 as the compilation version for the project. It should be noted that the eclipse installed the runtime environment installed in JDK 1.8

I also checked that none of the .classpath.impl or .project file is installed in the git repository.

Solution that worked for me: I just deleted the .classpath files and ran the maven-update project .. the classpath file was regenerated and it took 1.7 as a compiled version from the pom file.

+1
Feb 28 '17 at 17:59
source share

If you get the following type of error

Maven build error

Then follow these steps โ†’>

  • Go to Windows . Then select Settings , in which select java (in the left corner).
  • In java, select Installed JREs and check your JRE (if you installed jdk and certain environment variables correctly, you will see the current version of installed java here), as shown - installed jre

(I have Java 8 installed) Check the box if it is not installed . Click "Apply" and close.

Now press Alt + Enter to go to the project properties or right-click in the project and select "Properties".

In Properties, select Java Build Path in the left corner.

Choose Libraries

Check libraries

And click change (after selecting the JRE System Library ...) In the Press editor and select the default workspace JRE . Then click Finish

In Ordering and Exporting Check out the JRE library.

Then Finally Apply and close Clean up the project, and then build it.

Fixed issue .. Thanks!

+1
Sep 19 '17 at 18:28
source share

When creating a maven project in eclipse, the build path is set in JDK 1.5 regardless of the settings, which is probably an error in a new project or m2e.

0
Jul 27 '17 at 11:10
source share

I got an error in the Eclipse Mars version because "the build path indicates the J2SE-1.5 runtime. There are no JREs in the workspace that are strictly compatible with this environment.

To fix this problem, follow these steps: "Right-click on the project. Select the build path. Select" Configure the build path. "Select the" Libraries "tab. Select the JRE System Library and click the" Edit "button. Select the default workspace JRE and Finish

The problem will be solved.

-one
Jul 07 '17 at 6:25
source share



All Articles