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

java

Solution

You're looking for this on the command line (for a class called MyClass):

On Unix/Linux:

javap -verbose MyClass | grep "major"

On Windows:

javap -verbose MyClass | findstr "major"

You want the major version from the results. Here are some example values:

Java Version Major Version

1.2 46

1.3 47

1.4 48

5 49

6 50

7 51

8 52

9 53

10 54

11 55

12 56

13 57

14 58

15 59

16 60

17 61

18 62

19 63

20 64

21 65

Problem

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...

Original source

Related problems