by BehindJava

How to Fix the Java Exception java.lang.UnsupportedClassVersionError Unsupported major.minor version

Home » java » How to Fix the Java Exception java.lang.UnsupportedClassVersionError Unsupported major.minor version

If you have an old version of JVM, then it will not be able to read the code written in the latest versions. To overcome this issue, you need to update the JVM to the latest version. But, you cannot directly update the JVM as the version number of JVM is also changing. So, you need to compile your program again to make it compatible.

If you’re getting this error it means you have a newer version of Java than you have installed. The program is looking for the.

If the class file compiled for version 7, for instance, were designed for version 6, then the class might not be available.

So the solution is to either:

  • Upgrade your Java runtime.
  • Recompile the class if you have the source, using your local Java compiler (if you have one).


    For developers, this can happen if another developer checks in a .class file, and they’ve got a newer version of java than you have!

Another solution for IDE users:

  • Right click on your Project Properties -> Java Build Path -> Libraries.
  • Select your JRE System Library and click Edit on the right, and choose the target JRE.
  • Now go to Java Compiler on the left, and change the Compiler compliance level to your target.

The most common issue is misconfiguration of your JAVA_HOME variable which should point to the right Java Development Kit library, if you’ve multiple installed.

To find where SDK Java folder is located, run the following commands:

jrunscript -e 'java.lang.System.out.println(java.lang.System.getProperty("java.home"));'


To check which java (openjdk) you’ve installed, check via:

dpkg -l "openjdk*" | grep ^i


update-java-alternatives -l

To change it, use:

update-alternatives --config java

Prefix with sudo if required.

To select the alternative java version Or check which are available for install:

apt-cache search ^openjdk

Prefix with sudo if required.

Then you can install, for example:

apt-get install openjdk-7-jre

Prefix with sudo if required.

Fedora, Oracle Linux, Red Hat

Install/upgrade appropriate package via:

yum install java-1.7.0-openjdk java-1.7.0-openjdk-devel

The java-1.7.0-openjdk package contains just the Java Runtime Environment. If you want to develop Java programs then install the java-1.7.0-openjdk-devel package.


There is an OpenJDK 7 package in the FreeBSD Ports collection called (openjdk7)[] which probably needs to be reconfigured.

  • See: (OpenJDK wiki page)[].


Just install appropriate Java SE Development Kit library from the (Oracle site)[] or install


If you’re experiencing this issue with Jenkins, see:

  • (JENKINS-30561 - Unable to launch agent using SSH)[] However selecting the right version of Java (newer) with update-alternatives should work.