---
title: "M2Eclipse遭遇java.lang.UnsupportedClassVersionError"
author: "palmer"
date: "2010-04-01T06:01:30Z"
tags: []
categories: ["编程语言"]
slug: "m2eclipse-java-lang-unsupportedclassversionerror"
draft: false
lastmod: "2010-05-07T23:00:14Z"
id: 629615
url: "https://palmer.iteye.com/blog/629615"
---

转载 http://mail-archives.apache.org/mod\_mbox/maven-users/200810.mbox/%3C20262610.post@talk.nabble.com%3E

 

Maven 遭遇java.lang.UnsupportedClassVersionError:.... (Unsupported major.minor version 49.0)

 

 

Hi Thomas,

I had the same issue, when you configure the maven-compiler-plugin with java  
1.4 in your POM then m2eclipse automatically sets the 1.4 in the project  
build path, but then you have the exception you quote when you try to run  
maven commands.

I found several workarounds:

1\. Change the project configuration in Eclipse:  
   - in the Java Build path, set JRE 1.5 or 1.6  
   - in the Java Compiler configuration, set Compiler compliance level to  
1.4  
Then you will be able to run maven, and your compiled code will be  
compatible with Java 1.4  
The drawback is that you will not be able to let m2eclipse update the  
configuration (using Maven menu &gt; Update Project Configuration) else you  
lose this.

2\. Change the Maven configuration in Eclipse to use an external Maven  
program instead of the Embedder:  
Window &gt; Preferences &gt; Maven &gt; Installations  
Because it is the Maven Embedder that is used by default to run Maven  
programs and it requires Java 1.5 to work.

3\. Use a custom launch configuration for your maven command in Run  
Configurations... menu, there you can choose the Maven runtime to use  
instead of the Embedder, as explained here:  
http://docs.codehaus.org/display/M2ECLIPSE/Launching+Maven

There is a bug open about this issue:  
http://jira.codehaus.org/browse/MNGECLIPSE-798  
You can vote for it!

AmÃ©lie

thomas2004 wrote:  
&gt;  
&gt; Hi all,  
&gt;  
&gt; I use Eclipse Ganymede and I start it with Java 6. I've installed the  
&gt; maven plugin.  
&gt;  
&gt; But I configure a project with JRE of Java 1.4.2. As I run any maven  
&gt; command such as "mvn clean" or "mvn install", I got exception as follow.  
&gt; But as I change the JRE to Java 1.5, it's OK. But I do want to create  
&gt; project in Java 1.4. Any idea?  
&gt;  
&gt; java.lang.UnsupportedClassVersionError:  
&gt; org/apache/maven/artifact/resolver/AbstractArtifactResolutionException  
&gt; (Unsupported major.minor version 49.0)  
&gt;     at java.lang.ClassLoader.defineClass0(Native Method)  
&gt;     at java.lang.ClassLoader.defineClass(ClassLoader.java:539)  
&gt;     at  
&gt; java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)  
&gt;     at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)  
&gt;     at java.net.URLClassLoader.access$100(URLClassLoader.java:55)  
&gt;     at java.net.URLClassLoader$1.run(URLClassLoader.java:194)  
&gt;     at java.security.AccessController.doPrivileged(Native Method)  
&gt;     at java.net.URLClassLoader.findClass(URLClassLoader.java:187)  
&gt;     at java.lang.ClassLoader.loadClass(ClassLoader.java:289)  
&gt;     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)  
&gt;     at java.lang.ClassLoader.loadClass(ClassLoader.java:235)  
&gt;     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)  
&gt;     at  
&gt; org.apache.maven.cli.MavenCli.buildEmbedderConfiguration(MavenCli.java:204)  
&gt;     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:138)  
&gt;     at org.apache.maven.cli.MavenCli.main(MavenCli.java:63)  
&gt;     at org.apache.maven.cli.MavenCli.main(MavenCli.java:52)  
&gt; Exception in thread "main"  
&gt;

--  
View this message in context: http://www.nabble.com/java.lang.UnsupportedClassVersionError%3A....-%28Unsupported-major.minor-version-49.0%29-tp20228678p20262610.html  
Sent from the Maven - Users mailing list archive at Nabble.com.

\---------------------------------------------------------------------  
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org  
For additional commands, e-mail: users-help@maven.apache.org