Unsupported major.minor version XX.0 Error

When running Java, you may occasionally see an error such as java.lang.UnsupportedClassVersionError. This occurs when the running JVM tries to load a Java class version that it does not support.

Cause of the Error

This occurs when compiled Java bytecode is run on a JRE version lower than the version used at compile time.

Error Version Numbers Shown by Java Version

The number after Version means the following Java version.

  • J2SE 8 = Version 52
  • J2SE 7 = Version 51
  • J2SE 6.0 = Version 50
  • J2SE 5.0 = Version 49
  • JDK 1.4 = Version 48
  • JDK 1.3 = Version 47
  • JDK 1.2 = Version 46
  • JDK 1.1 = Version 45

What to Check

Check the Java version used when the error occurred.

$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

How to Fix It

The possible fixes are as follows.

  • Recompile with the version used for execution above. Compiling for a lower version may cause source-code errors.
  • Change the runtime Java version (JRE) to a newer version and run it again.

References

http://dwfox.tistory.com/25