Who doesn’t know java’s exception java.lang.UnsupportedClassVersionError?

Java throws the exception when class is compiled to a newest version of Virtual Machine that is trying to run. For instance, run a class compiled to J2SE 5 in a JRE 1.4

There’s many ways to find the version from a .class file. One of then need a hexadecimal editor to verify the Magic Numbers. An another way, the easier way, you’ll just need run the command javap.

javap are located in $JAVA_HOME/bin (same path of javac and java).

Run:

javap -v <class_file_path>/Test.class

You will able to check the version in “major version” line.

Classfile /C:/Users/USER/Test.class
 Last modified 26/08/2014; size 532 bytes
 MD5 checksum cb9054fefbbaa410d3asd38fb82c7c54afb
 Compiled from "Test.java"
 public class Test
 SourceFile: "Test.java"
 minor version: 0
 major version: 51
...

With this result we discovered that class was compiled to version 51 (JRE 7).

You can find respective JRE version in table above:

Number version JRE version
52 J2SE 8
51 J2SE 7
50 J2SE 6
49 J2SE 5
48 JDK 1.4
47 JDK 1.3
46 JDK 1.2
45 JDK 1.1

Don’t forget about to comment if it helped!
Enjoy!