Java unsupported major minor version 52.0

If you are reading this then perhaps you are having java version mismatch. Several apps based on implementations may present you with errors such as class not found error (yes! That’s what R did to me) or class version error – java.lang.UnsupportedClassVersionError: Unsupported major.minor version.

java.lang.UnsupportedClassVersionError occurs because a higher JDK was used during compile-time and lower JDK is used during run-time.

 

So how do we check for mismatching java versions?

Check runtime java version

$ java -version

Check java version of class file

javap -verbose MyClass | grep "major"
# On Windows
javap -verbose MyClass | findstr "major"

 

Using above commands you can ensure that the java version is cause troubles.

Below are some more commands and tips to expedite your diagnosis

Looking for a class file inside a jar

$ jar tvf target/my-jar-with-dependencies.jar | grep hadoop/conf/Configuration.class

Generating backward compatible java class

For example, in order to generate class files compatible with Java 1.4, use the following command line:

javac -target 1.4 HelloWorld.java

Stuff related to R

Enable debug for better diagnosis,
using –

> .jclassLoader()$setDebug(1L)

so you can see the actual reason

Check java version in R

> J("java.lang.System")$getProperty("java.version")

 

Resources

  1. https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi
  2. https://stackoverflow.com/questions/1342894/find-a-class-somewhere-inside-dozens-of-jar-files
  3. https://github.com/s-u/RJDBC/issues/26
  4. https://stackoverflow.com/questions/1096148/how-to-check-the-jdk-version-used-to-compile-a-class-file

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *