Obtaining java versions from compiled .class files

From http://www.rgagnon.com/javadetails/java-0544.html


The first 4 bytes are a magic number, 0xCAFEBABe, to identify a valid class file then the next 2 bytes identify the class format version (major and minor).

Possible major/minor value :

major  minor Java platform version 
45 3 1.0
45 3 1.1
46 0 1.2
47 0 1.3
48 0 1.4
49 0 1.5
50 0 1.6


So, all you need to do is, open the .class file in binary mode in a text editor and look at the first 8 bytes.

For e.g., here are the first 8 bytes (hex) from a .class file: CA FE BA BE 00 00 00 30

This makes it a java class compiled either under JDK1.4, or at the very least, compiled with 1.4 compatibility turned on.