Menu:

Java Tidbits

A collection of informative Java tidbits.

Java Class Versions and UnsupportedClassVersionError

An UnsupportedClassVersionError is thrown when the Java Virtual Machine reads a class file and version stamp in the file is not supported.

This will happen when you compile a class with a version of the compiler that is newer than the JVM you then run it on. For example, compiling a class with Java 5 and running it on Java 1.4.2 will give you an error like:

java.lang.UnsupportedClassVersionError: SomeClass (Unsupported major.minor version 49.0)

It is handy to know what version the JVM is talking about since 49.0 does not map in my brain to Java 5.

Java Class Version Table
Class Version
Java Version
50.0
1.7.0-ea-b24
50.0
1.6.0
49.0
1.5.0
48.0
1.4.2
47.0
1.3.1
46.0
1.2.2

The class version is available programmatically in the java.class.version system property:

public class Test {
public static void main(String[] arguments) {
System.out.println(System.getProperty("java.class.version"));
}
}