Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.UnsupportedClassVersionError Unsupported major.minor version 51.0 [duplicate]

I am trying to build an application, but it gives some error. My JDK version is given below:

java version "1.6.0_30" Java(TM) SE Runtime Environment (build 1.6.0_30-b12) Java HotSpot(TM) Client VM (build 20.5-b03, mixed mode, sharing) 

Here is my Error Log:

Buildfile: build.xml  compile:      [echo] Compiling the service....      [echo]   ...mkdir for classes first....      [echo]   ...java classes next....      [echo]   ...mkdir for generated code next....      [echo]  ...generate stubs/skeletons next.... [wscompile] command line: wscompile -d /home/vivekray/program/MTrans/WEB-INF/classes -features:wsi,documentliteral -gen:server -keep -model /home/vivekray/program/MTrans/WEB-INF/model.gz -verbose -Xprintstacktrace /home/vivekray/program/MTrans/src/config.xml -classpath /home/vivekray/program/MTrans/WEB-INF:/home/vivekray/program/MTrans/WEB-INF/classes:/home/vivekray/program/MTrans/lib/log4j-1.2.16.jar:/home/vivekray/jwsdp-2.0/jwsdp-shared/lib/mail.jar:/home/vivekray/jwsdp-2.0/jwsdp-shared/lib/activation.jar:/home/vivekray/jwsdp-2.0/jaxp/lib/jaxp-api.jar:/home/vivekray/jwsdp-2.0/jaxp/lib/endorsed/dom.jar:/home/vivekray/jwsdp-2.0/jaxp/lib/endorsed/sax.jar:/home/vivekray/jwsdp-2.0/jaxp/lib/endorsed/xalan.jar:/home/vivekray/jwsdp-2.0/jaxp/lib/endorsed/xercesImpl.jar:/home/vivekray/jwsdp-2.0/jaxrpc/lib/jaxrpc-api.jar:/home/vivekray/jwsdp-2.0/jaxrpc/lib/jaxrpc-spi.jar:/home/vivekray/jwsdp-2.0/jaxrpc/lib/jaxrpc-impl.jar:/home/vivekray/jwsdp-2.0/saaj/lib/saaj-api.jar:/home/vivekray/jwsdp-2.0/saaj/lib/saaj-impl.jar:/home/vivekray/jwsdp-2.0/jwsdp-shared/lib/relaxngDatatype.jar:/home/vivekray/jwsdp-2.0/jwsdp-shared/lib/xsdlib.jar:/home/vivekray/jwsdp-2.0/jwsdp-shared/lib/jax-qname.jar:/home/vivekray/jwsdp-2.0/apache-ant/lib/ant.jar:/home/vivekray/jwsdp-2.0/fastinfoset/lib/FastInfoset.jar:/home/vivekray/Softwares/apache-tomcat-7.0.27/lib/servlet-api.jar [wscompile] [creating model: mtransservice] [wscompile] [creating service: Mtransservice]  BUILD FAILED java.lang.UnsupportedClassVersionError: in/cdac/mobile/computing/mtrans/MtransService : Unsupported major.minor version 51.0     at java.lang.ClassLoader.defineClass1(Native Method)     at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)     at java.lang.ClassLoader.defineClass(ClassLoader.java:615)     at org.apache.tools.ant.AntClassLoader.defineClassFromData(AntClassLoader.java:1146)     at org.apache.tools.ant.AntClassLoader.getClassFromStream(AntClassLoader.java:1324)     at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1388)     at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1341)     at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1088)     at java.lang.ClassLoader.loadClass(ClassLoader.java:295)     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)     at java.lang.Class.forName0(Native Method)     at java.lang.Class.forName(Class.java:247)     at com.sun.xml.rpc.processor.modeler.rmi.RmiUtils.getLoadableClassName(RmiUtils.java:78)     at com.sun.xml.rpc.processor.modeler.rmi.RmiUtils.getRealName(RmiUtils.java:54)     at com.sun.xml.rpc.processor.modeler.rmi.RmiModeler.modelPort(RmiModeler.java:676)     at com.sun.xml.rpc.processor.modeler.rmi.RmiModeler.buildLiteralModel(RmiModeler.java:603)     at com.sun.xml.rpc.processor.modeler.rmi.RmiModeler.buildModel(RmiModeler.java:457)     at com.sun.xml.rpc.processor.config.ModelInfo.buildModel(ModelInfo.java:88)     at com.sun.xml.rpc.processor.Processor.runModeler(Processor.java:63)     at com.sun.xml.rpc.tools.wscompile.CompileTool.run(CompileTool.java:714)     at com.sun.xml.rpc.util.ToolBase.run(ToolBase.java:43)     at com.sun.xml.rpc.tools.ant.Wscompile.execute(Wscompile.java:746)     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)     at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)     at java.lang.reflect.Method.invoke(Method.java:597)     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)     at org.apache.tools.ant.Task.perform(Task.java:348)     at org.apache.tools.ant.Target.execute(Target.java:357)     at org.apache.tools.ant.Target.performTasks(Target.java:385)     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)     at org.apache.tools.ant.Project.executeTarget(Project.java:1306)     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)     at org.apache.tools.ant.Project.executeTargets(Project.java:1189)     at org.apache.tools.ant.Main.runBuild(Main.java:758)     at org.apache.tools.ant.Main.startAnt(Main.java:217)     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)  Total time: 1 second 
like image 436
vivek rai Avatar asked Jun 28 '12 06:06

vivek rai


People also ask

How do I fix Java Lang UnsupportedClassVersionError in Java?

UnsupportedClassVersionError happens because of a higher JDK during compile time and lower JDK during runtime. How can i make above change? Project -> Properties -> Java Compiler Enable project specific settings. Then select Compiler Compliance Level to 1.7, 1.6 or 1.5, build and test your app.

What is UnsupportedClassVersionError in Java?

Class UnsupportedClassVersionErrorThrown when the Java Virtual Machine attempts to read a class file and determines that the major and minor version numbers in the file are not supported.

When my class encounter UnsupportedClassVersionError which option would resolve this issue?

1) If you encounter UnSupportedClassVersionError, check the JRE version you are using to run program and switch to higher version for quick solution.

What is Major Minor version in Java?

minor version error is thrown in Java when a class is compiled using a higher version of the Java Development Kit (JDK) but executed on a lower version of the Java Runtime Environment (JRE). The exact cause is printed on the version e.g. in the case of major.

How to fix unsupportedclassversionerror - unsupported major?

As you know now that root cause of any java.lang.UnsupportedClassVersionError: Unsupported major.the minor version is incompatible JRE version at run-time, but changing JRE is not the only solution you have, you can even compile your class file for lower JRE version. In order to adapt this solution, you need to re-compile your project.

How to fix unsupported major version 51 0 error in Java?

Simplest solution to fix Unsupported major.minor version 51.0 error changes your Java virtual machine. Upgrade JRE to get a version the same or higher than the version you have used for compiling your project. Once you got that, just run your program again. It should work fine this time.

What is unsupported class version error in Eclipse?

When you run a program in Eclipse or command line. You may encounter the following exception java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0. This is because your java class compiler version is bigger than the java class runtime version.

Why do I get error Helloworld unsupported major 52?

If you are getting "java.lang.unsupportedclassversionerror HelloWorld unsupported major.minor version 52.0", which means Java version in your PATH is lesser than Java 8. If you already installed the JDK 1.8 then its due to incorrect PATH setting.


2 Answers

These guys gave you the reason why is failing but not how to solve it. This problem may appear even if you have a jdk which matches JVM which you are trying it into.

Project -> Properties -> Java Compiler

Enable project specific settings.

Then select Compiler Compliance Level to 1.6 or 1.5, build and test your app.

Now, it should be fine.

like image 199
Capagris Avatar answered Oct 28 '22 20:10

Capagris


java.lang.UnsupportedClassVersionError happens because of a higher JDK during compile time and lower JDK during runtime.

Here's the list of versions:

Java SE 9 = 53, Java SE 8 = 52, Java SE 7 = 51, Java SE 6.0 = 50, Java SE 5.0 = 49, JDK 1.4 = 48, JDK 1.3 = 47, JDK 1.2 = 46, JDK 1.1 = 45 
like image 42
Vivek Kumar Ray Avatar answered Oct 28 '22 20:10

Vivek Kumar Ray