What does UnsupportedClassVersionError mean?

Every time the structure of Java byte-code changes, the version number embedded in .class files must also change.

Java 1.2 uses major version 46
Java 1.3 uses major version 47
Java 1.4 uses major version 48
Java 5 uses major version 49
Java 6 uses major version 50
Java 7 uses major version 51
Java 8 uses major version 52

Each newer version of Java fully supports classes compiled with an older Java version. A class file complied with JDK 6 is supported on Java 7 and Java 8, but it is not supported by Java 5 or earlier.

If a .class file compiled with a later JDK version is attempted to be used on an older Java version, then the java.lang.UnsupportedClassVersionError is raised by the Java runtime.

For example given this error:

java.exe -jar ords.war

Exception in thread "main" java.lang.

UnsupportedClassVersionError: oracle/dbtool
s/jarcl/Entrypoint (Unsupported major.minor version 50.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)

We can deduce that the Java version being used is Java 5 or earlier, since Java 6 or later will fully support .class files with a major version number of 50.

The Java version being used can be checked using the following command:

java -version

On UNIX systems, you can also use the which command to determine which Java executable is being used. On Windows you can use the where command.

In the above example it turned out that a 1.4.2 JRE that shipped with another product, was being picked up because of the way the Windows PATH environment variable was configured.