Maven eclipse - Main.minor version 52.0 is not supported

I am using apache maven 3.2.3 to compile my java project.

When I use the command line to start compilation with

mvn clean compile 

then it works great.

But when I run maven build from eclipse (LUNA), it always fails with the error below:

 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project MSDPEx: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile: java.lang.UnsupportedClassVersionError: com/sun/tools/javac/Main : Unsupported major.minor version 52.0 [ERROR] ----------------------------------------------------- [ERROR] realm = plugin>org.apache.maven.plugins:maven-compiler-plugin:2.5.1 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [ERROR] urls[0] = file:/home/rvnath/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/2.5.1/maven-compiler-plugin-2.5.1.jar [ERROR] urls[1] = file:/home/rvnath/.m2/repository/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.jar [ERROR] urls[2] = file:/home/rvnath/.m2/repository/org/codehaus/plexus/plexus-compiler-api/1.9.1/plexus-compiler-api-1.9.1.jar [ERROR] urls[3] = file:/home/rvnath/.m2/repository/org/codehaus/plexus/plexus-compiler-manager/1.9.1/plexus-compiler-manager-1.9.1.jar [ERROR] urls[4] = file:/home/rvnath/.m2/repository/org/codehaus/plexus/plexus-compiler-javac/1.9.1/plexus-compiler-javac-1.9.1.jar [ERROR] urls[5] = file:/home/rvnath/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar [ERROR] Number of foreign imports: 1 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]] [ERROR] [ERROR] ----------------------------------------------------- [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. 

Is there a configuration problem with eclipse and maven? If so, how to solve it?

If this helps, my environment is below:

 OS: Ubuntu 14.10 JDK: java version "1.7.0_75" OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-1~utopic1) OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode) Eclipse installed JRE's: java-7-openjdk-amd64 (default) 
+6
source share
3 answers

Firstly. If you are working with Maven, the truth is in the pom file, not in Eclipse. Therefore, you need to solve the problem in Maven, not in Eclipse.

First you need to update the maven-compiler plugin to version 3.2 or 3.3. and configure it as follows:

 <project> [...] <build> [...] <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> [...] </build> [...] </project> 

You should check your build from the command line, not from an eclipse. In addition, you should know the difference between using the source , target and JDK options.

+2
source

This problem has bothered me over the past 2 ... 3 weeks.

This question has been asked several times and many answers. But also send my answer, so someone who has such a situation can be useful.

Finally, I realized that my system also installed jdk1.8, and that running maven using cmdline used this version, while eclipse used 1.7. So, I did the following:

  • open Eclipse-> Window-> preferences-> Installed JRE
  • click the "Add" button, select the path to my jdk1.8, complete

Now I can compile the project, although I don’t know the exact reason why it should not be compiled with jdk1.7.

+8
source

Above did not work for me, but it was. Add to pom.xml

 <project ....> <properties> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </properties> </project> 

where 1.7 is the version of Java you are going to use. This overwrites the maven compiler setting, so it's good to debug here.

0
source

Source: https://habr.com/ru/post/984348/


All Articles