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.
-
In maven build configuration also I am setting jdk version to be 1.8 – Akash Singh Jan 27 '22 at 05:18
-
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 – Umeshwaran Jan 27 '22 at 07:00
-
In your `pom.xml` the _project_ element should contain `
` for that. – howlger Jan 27 '22 at 11:281.8 1.8
2 Answers
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

- 627
- 6
- 12
-
Yes all that I have already done, everywhere I had done 1.8. But due to some reason, when I build/update the project the JRE is getting changed to J2SE 1.5. I am not sure why this is happening. – Akash Singh Jan 27 '22 at 09:33
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?

- 627
- 6
- 12