Java – How to Fix java.lang.UnsupportedClassVersionError Error?

This article represents tips on how to fix Java error such as UnsupportedClassVersionError. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos.
How to Reproduce the Error?
  • Set the JAVA_HOME with one version of Java. And, include “bin” of different Java version in PATH variable.
  • Compile the class, say, with “javac” command
  • Start the JVM with following class: “java HelloWorld”

With above, you could see error such as following:

java.lang.UnsupportedClassVersionError: HelloWorld : Unsupported major.minor ver
sion 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at Source)
        at Source)
        at$100(Unknown Source)
        at$ Source)
        at$ Source)
        at Method)
        at Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

I set the JAVA_HOME for jdk 8.* and set the jdk7.* in PATH.

How to Fix the java.lang.UnsupportedClassVersionError?

Make sure that same version is set as JAVA_HOME as included in PATH variable (%JAVA_HOME%/bin)


Ajitesh Kumar
Follow me

Leave A Reply

Time limit is exhausted. Please reload the CAPTCHA.