Deepu
Deepu

Reputation: 2616

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

Recently I am the facing problem with Apache Tomcat 6.0.35 on Linux Centos. I am getting the error -

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

When I give the command -

java -version

It 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

It shows -

javac 1.6.0_22

To locate the Java I give the command -

whereis java

The output is -

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

And for

which java

It displays -

/usr/bin/java

Also for

which javac

Output is

/usr/bin/javac

Where myApp is java project developed in Windows and Uploaded the WAR file in Tomcats' webapp directory on Linux.

I am not getting what is happening? Please can anybody please help me to resolve the problem?

Thanks in advance.

Upvotes: 8

Views: 12034

Answers (3)

basiljames
basiljames

Reputation: 4847

The exception is because yor code is compiled using a higher version than the one you are trying to run it on. In your windows machine you might be using windows 7 to build the war. Check javac -version in your windows machine.

Upvotes: 3

Peter Svensson
Peter Svensson

Reputation: 6173

Looks like your code is compiled with jdk7?

Upvotes: 1

ziesemer
ziesemer

Reputation: 28697

You need a Java 7 runtime, not Java 6. See http://en.wikipedia.org/wiki/Java_class_file#General_layout for some details concerning this.

Alternatively, you need to find and/or re-compile your code to be compatible with Java 6.

Upvotes: 6

Related Questions