Java.lang.UnsupportedClassVersionError: myApp: Unsupported version of major.minor 51.0 (cannot load myApp class) On Linux

I recently ran into Apache Tomcat 6.0.35 on Linux Centos. I get an error -

java.lang.UnsupportedClassVersionError: myApp : Unsupported major.minor version 51.0 (unable to load class myApp) 

When I give a command -

 java -version 

Shows

 java version "1.6.0_22" OpenJDK Runtime Environment (IcedTea6 1.10.9) (rhel-1.28.1.10.9.el5_8-x86_64) OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode) 

Similarly, when I give the command -

 javac -version 

He shows -

 javac 1.6.0_22 

To find Java, I give the command -

 whereis java 

Exit -

 java: /usr/bin/java /etc/java /usr/lib/java /usr/share/java /usr/share/man/man1/java.1.gz 

And for

 which java 

Displayed -

 /usr/bin/java 

Also for

 which javac 

Exit

 /usr/bin/javac 

Where myApp is a java project developed on Windows and the WAR file is loaded into the Tomcats Linux webapp directory.

I do not understand what's going on? Please someone please help me solve the problem?

Thanks in advance.

+8
java linux tomcat
source share
3 answers

You need the Java 7 runtime, not Java 6. For more information, see http://en.wikipedia.org/wiki/Java_class_file#General_layout .

Alternatively, you need to find and / or recompile your code for compatibility with Java 6.

+6
source share

The exception is that yor code is compiled using a higher version than the one you are trying to run. In your Windows machine, you can use Windows 7 to create war. Check javac -version on your windows computer.

+3
source share

Does your code seem to be compiled using jdk7?

+1
source share

All Articles