Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0 (unable to load class frontend.listener.StartupListener) [duplicate]

Tags:

java

tomcat

Possible Duplicate:
unsupported major .minor version 51.0

I have eclipse indigo and tomcat 7.0.29. And still no Serlvets can be loaded! I have no other JDK or JRE than the 1.7 one!

  • Compilance level 1.7
  • JAVA_HOME point to JDK 1.7
  • JAVA_JRE point to JRE 1.7
  • build path contains JDK 1.7
  • Java Facet 1.7

..but still Unsupported major.minor version 51.0

like image 242
Hlib Avatar asked Aug 19 '12 16:08

Hlib


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.

When my class encounter UnsupportedClassVersionError which option could 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 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.


1 Answers

What is your output when you do java -version? This will tell you what version the running JVM is.

The Unsupported major.minor version 51.0 error could mean:

  • Your server is running a lower Java version then the one used to compile your Servlet and vice versa

Either way, uninstall all JVM runtimes including JDK and download latest and re-install. That should fix any Unsupported major.minor error as you will have the lastest JRE and JDK (Maybe even newer then the one used to compile the Servlet)

See: http://www.java.com/en/download/manual.jsp (7 Update 25 )

and here: http://www.oracle.com/technetwork/java/javase/downloads/index.html (Java Platform (JDK) 7u25)

for the latest version of the JRE and JDK respectively.

EDIT:

Most likely your code was written in Java7 however maybe it was done using Java7update4 and your system is running Java7update3. Thus they both are effectively the same major version but the minor versions differ. Only the larger minor version is backward compatible with the lower minor version.

Edit 2 : If you have more than one jdk installed on your pc. you should check that Apache Tomcat is using the same one (jre) you are compiling your programs with. If you installed a new jdk after installing apache it normally won't select the new version.

like image 141
David Kroukamp Avatar answered Oct 16 '22 06:10

David Kroukamp