Home > database >  Eclipse building the project with a different JRE than the one provided in java build path
Eclipse building the project with a different JRE than the one provided in java build path

Time:01-27

I am new to eclipse and trying to run a spring application with a number of modules. I am setting the build path and compiler to use jdk 1.8 but when I run maven install it is building the project using JRE 1.5 for all the modules somehow. I checked the pom.xml but no where the compiler version was defined. I wanted to know if anyone can help me with the reasons why I may be facing this issue.

CodePudding user response:

Right click on the project . Go to "Properties" . Select "Java" in the left pane, and choose "Installer JRE" . See which JRE is pointed to . If you want , change it to your desired jre. If that is in correct configuration, then choose "Compiler " option under "Java" and check the Java version used. If it points to 1.5 , override it to 1.8 and check again .

So In anyone of these places , java might be pointed to 1.5 .

If all the above are good , check the java path in environment variables and check if it points to 1.5 or 1.8

CodePudding user response:

If you want to make sure that newly created projects in Eclipse use another default java version than Java 1.5, you can change the configuration in the maven-compiler-plugin.

Go to the folder .m2/repository/org/apache/maven/plugins/maven-compiler-plugin/3.1 Open maven-compiler-plugin-3.1.jar with a zip program. Go to META-INF/maven and open the plugin.xml In the following lines:

${maven.compiler.source} ${maven.compiler.target}

change the default-value to 1.7 or 1.8 or whatever you like.

Save the file and make sure it is written back to the zip file. From now on, all new Maven projects use the java version you specified.

Information is from the following blog post: https://sandocean.wordpress.com/2019/03/22/directly-generating-maven-projects-in-eclipse-with-java-version-newer-than-1-5/

More Link : Why Maven project is tied to J2SE-1.5 by default?

What causes imported Maven project in Eclipse to use Java 1.5 instead of Java 1.6 by default and how can I ensure it doesn't?

  •  Tags:  
  • Related