java.lang.UnsupportedClassVersionError: Bad version number in .class file

Problem

I use a JDK1.6 to compile a class file, WAR it and deploy to Tomcat server (another machine), but Tomcat server JAVA_HOME or JRE_HOME environment variable is set to JDK.1.5, and causing :

java.lang.UnsupportedClassVersionError: 
Bad version number in .class file

Solution

This is always caused by the conflict of different Java JDK at compile time and runtime, make sure you are using same JDK version to compile and run it.

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
3 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
ravi sasrafulOnur Recent comment authors
newest oldest most voted
Onur
Guest
Onur

fast solution, thanks

asraful
Guest
asraful

is there any tool which help me to find specifically which jar is compiled in newer version but trying to run on earlier version, from mainfest file one can find , but while i have lot of jars and , need to downgrade from jdk 1.6 to jdk 1.5.22 so need to find which jar has version mismatch

ravi s
Guest
ravi s

thanks,