Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Supporting Your Unsupported Class Version Error [Code Snippet]

DZone's Guide to

Supporting Your Unsupported Class Version Error [Code Snippet]

Here's a quick fix if you're running into the UnsupportedClassVersionError. It could be as simple as making sure your PATH variable is playing nicely with JAVA_Home.

· Java Zone ·
Free Resource

Verify, standardize, and correct the Big 4 + more– name, email, phone and global addresses – try our Data Quality APIs now at Melissa Developer Portal!

This article covers how to fix Java errors akin to UnsupportedClassVersionError. Please feel free to comment/suggest if I missed something.

How to Reproduce the Error

  • Set JAVA_HOME with one version of Java. Include a “bin” of different Java versions in the PATH variable.
  • Compile the class, for example HelloWorld.java, with “javac”.
  • Start the JVM with following class: “java HelloWorld”.

With the steps above, you might see an error like:

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 java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown 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.

Basically, you want to make sure that same version is set as JAVA_HOME as it's included in the PATH variable (%JAVA_HOME%/bin). That should fix your problem!

Developers! Quickly and easily gain access to the tools and information you need! Explore, test and combine our data quality APIs at Melissa Developer Portal – home to tools that save time and boost revenue. Our APIs verify, standardize, and correct the Big 4 + more – name, email, phone and global addresses – to ensure accurate delivery, prevent blacklisting and identify risks in real-time.

Topics:
java ,error ,unsupportedclassversionerror

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}