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).

    javac FileName.java

    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.