Java Examples
Java Examples
memu home questions

Why do I get an "Unsupported major.minor version" when I run a java program?

You will get this type of exception when you run the program with a lower version of the JDK then it was compiled with.

The example program was compiled with JDK 1.7 and is run with JDK 1.6


$ java HelloWorld 
Exception in thread "main" java.lang.UnsupportedClassVersionError: 
  HelloWorld : Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(
	at java.lang.ClassLoader.defineClass(
	at Method)
	at java.lang.ClassLoader.loadClass(
	at sun.misc.Launcher$AppClassLoader.loadClass(
	at java.lang.ClassLoader.loadClass(
Could not find the main class: HelloWorld.  Program will exit.

$ java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode)

Reported major numbers:

JDK 1.8 = 52
JDK 1.7 = 51
JDK 1.6 = 50
JDK 1.5 = 49
JDK 1.4 = 48
JDK 1.3 = 47
JDK 1.2 = 46
JDK 1.1 = 45

Questions answered by this page:

How to fix: Unsupported major.minor version 51.0 error? Runtime Java error: (Unsupported major.minor version 49.0)