[java] how to check the jdk version used to compile a .class file

Possible Duplicate:
Tool to read and display Java .class versions

I'm trying to debug a

"Bad version number in .class file'

error in java, is there a way for me to check which version the .class files are?

I'm using JRE1.5.0_6, but my JDK is version 1.6.0_13.

I'm compiling with compatibility mode set to 1.5 in eclipse which I thought would work...

This question is related to java

The answer is


Btw, the reason that you're having trouble is that the java compiler recognizes two version flags. There is -source 1.5, which assumes java 1.5 level source code, and -target 1.5, which will emit java 1.5 compatible class files. You'll probably want to use both of these switches, but you definitely need -target 1.5; try double checking that eclipse is doing the right thing.


You can try jclasslib:

https://github.com/ingokegel/jclasslib

It's nice that it can associate itself with *.class extension.


Free JarCheck tool here


Does the -verbose flag to your java command yield any useful info? If not, maybe java -X reveals something specific to your version that might help?