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
53.0
1.9.0 Early Access build 107
52.0
1.9.0 before Early Access build 107
52.0
1.8.0
51.0
1.7.0
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"));
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s