Java version automatically changes to java 1.5 after maven update

I am using eclipse as an IDE. When I right-click on the project, and then click maven, upgrade my version of Java version to 1.5. Here is what I have done so far; I have followed all the steps listed here.

http://qussay.com/2013/09/13/solving-dynamic-web-module-3-0-requires-java-1-6-or-newer-in-maven-projects/

  • I changed the "Java build path" to "workspace default jre 1.8.0_25"
  • Then the "java compiler" changed to 1.8
  • Then the "project face"> java> 1.8 changed
  • Changed java version of pom.xml to version 1.8
<build> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.1.3.v20140225</version> </plugin> <plugin> <groupId>org.apache.maven.plugin</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> 

After all this, when I click "Update Maven", my version of Java will change to 1.5 automatically. Also in the above steps, the first two-stage version also automatically changes to 1.5. How can i fix this?

+74
java eclipse maven
Feb 13 '15 at 22:36
source share
9 answers

Open the pom.xml file and add the following lines to 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 to do this is to add <build> with 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> 
+145
Feb 13 '15 at 22:44
source share

I had the same problem when I installed Java 9. By default, my project used the J2SE-1.5 runtime. Strange, but the Java 9 compliance level is referenced not like in previous versions, that is, “1.8”, but “9”. Therefore, I had to provide my properties and Maven plug-in configuration accordingly:

 <properties> <maven.compiler.source>9</maven.compiler.source> <maven.compiler.target>9</maven.compiler.target> </properties> 

as well as

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>9</source> <target>9</target> </configuration> </plugin> 

This seems to have solved the problem.

+7
Apr 7 '18 at 13:41
source share

The main reason for this problem is that if for some reason Eclipse cannot resolve the valid value for the maven.compiler.source property when creating / updating the .classpath file from pom, it is just the default to use org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5 .

As @ jorge-campos expertly replied, there are many ways to set this property.

However, Jorge's answer did not seem to work for me. Here are my settings:

 <properties> <javaVersion>1.8</javaVersion> <maven.compiler.source>${java.version}</maven.compiler.source> <maven.compiler.target>${java.version}</maven.compiler.target> </properties> 

...

That's right. ${java.version} never going to ${java.version} (completely different) javaVersion property, and Eclipse ignores the property and uses the default value.

Which brings me back to the " for any reason " section that I opened; Developer stupidity may be one of those reasons.

+4
Dec 09 '17 at 18:15
source share

Add these lines to your pom.xml, then right-click on your JRE system library -> Properties -> Install the correct runtime on Java 1.8 or the version you want to install.

 <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> 
+2
Jul 28 '17 at 20:19
source share

I had this problem. In my case, the <properties> tag and nested tags that Jorge Campos mentioned were in the wrong place. If I put them between the <hostversion> and <dependencies> tags in the pom.xml file, then this behavior stopped.

This can be picked up in Eclipse if checking for these files is enabled.

+1
Apr 27 '16 at 12:36
source share

I am facing a similar problem on one of my teams. He used an old version of Eclipse, I believe he used Keppler. The project after the upgrade changes the version of JRE to 1.5.

A simple upgrade of Eclipse to the latest version solves this problem.

+1
Jul 6 '16 at 8:31
source share

I will allow myself to update this theme using Java 11.

I installed OpenJDK11 on my computer and wanted to use it in the application.

I had problems because Eclipse always changed the JRE to JavaSE-1.5 when I updated my project using Maven.

I installed everything as you said, but I always directly chose "java-11-openjdk.x86_64" in my Java Build Path as one of my Alternante JREs. I fixed my problem by selecting JavaSE-10 in the "runtime" (but you should double-click on it and then select your version of OpenJDK11 as the compatible JRE), as shown in the figure. Runtime Setup

Thanks to this, Java 11 will be used in the project, but you need to write 10 for the java version in pom.xml, and also install java 10 for the project faces.

0
Dec 12 '18 at 2:04
source share

In my case (the old JBoss Developer Studio) the problem was that the JRE did not include 1.8 (only 1.7). When I switched the maven-compiler-plugin version to 1.7 and completed the maven update project, it upgraded the Eclipse JRE system library to 1.7. enter image description here

Thus, the solution is to either get a newer version of the IDE, including the built-in JRE version 1.8 or later, or try to install it manually (see https : //stackoverflow.com/a/262880/... ).

0
Feb 04 '19 at 17:23
source share

I changed Eclipse from Kepler to neon and then updated my project using Maven -> Update Project.

-3
Jul 27 '17 at 8:50
source share



All Articles