Skip to content
Advertisement

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

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.

Advertisement

Answer

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?

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement