Unsupported major.minor version Error

Unsupported major.minor version error is because of Java version mismatch. It happens when you compile your projects on higher version of java(e.g. jdk 1.8) and then run it on a lower version (e.g. jdk 1.7). Depending on your situation, you have two ways to resolve this error: compile your code for an earlier version of Java, or run your code on a newer Java version. Sometimes you may have more than one version of Java SDK installed in your machine. Make sure the application you are running is pointing to the right or highest version available . It is better you need to install both JRE/JDK with the same version.
what is java.lang.UnsupportedClassVersionError: Unsupported major.minor version

Java minor_version, major_version

The values of the minor_version and major_version items are the minor and major version numbers of this Java class file. Together, a major and a minor version number determine the version of the .class file format. If a class file has major version number M and minor version number m, we denote the version of its class file format as M.m. Thus, class file format versions may be ordered lexicographically , for example, 1.5 < 2.0 < 2.1.

Major version number of the class file format being used.

  1. Java SE 14 = 58 (0x3A hex)
  2. Java SE 13 = 57 (0x39 hex)
  3. Java SE 12 = 56 (0x38 hex)
  4. Java SE 11 = 55 (0x37 hex)
  5. Java SE 10 = 54 (0x36 hex)
  6. Java SE 9 = 53 (0x35 hex)
  7. Java SE 8 = 52 (0x34 hex)
  8. Java SE 7 = 51 (0x33 hex)
  9. Java SE 6.0 = 50 (0x32 hex)
  10. Java SE 5.0 = 49 (0x31 hex)
  11. JDK 1.4 = 48 (0x30 hex)
  12. JDK 1.3 = 47 (0x2F hex)
  13. JDK 1.2 = 46 (0x2E hex)
  14. JDK 1.1 = 45 (0x2D hex)

Java Compatibility

Java strongly tries to be backward compatible but sometimes changes that are not backward compatible are necessary to evolve the ecosystem . Usually, many people think why do you get a version mismatch error if Java is backward compatible . Well, its true that Java is backward compatible, which means you can run a Java class file or Java binary (JAR file) compiled in lower version (java 6) into higher version e.g. Java 8, but it doesn't mean that you can run a class compiled using Java 7 into Java 5, it is because higher version usually have features which are not supported by lower version . For e.g. Unsupported major.minor version 52.0 comes when you are trying to run a class compiled using Java 1.8 compiler into a lower JRE version e.g. JRE 1.7 or JRE 1.6. To fix the actual problem you should try to either run the Java code with a newer version of Java JRE or specify the target parameter to the Java compiler to instruct the compiler to create code compatible with earlier Java versions .

Eclipse

If you're using Eclipse you should do 2 things: In Eclipse, click on Window > Preferences , and in the window that appears, on the left side, under Java , click on Installed JREs , click on Add... and navigate to the folder that contains the JDK.
Eclipse  java.lang.UnsupportedClassVersionError: Unsupported major.minor version
Select the check box to activate the required version of JRE. Right-click on your project and click on Properties , in the window that appears, on the left side, click on Java Compiler and uncheck Use compliance from execution environment on the Java Build Path, this allows you to choose in the list Compiler compliance level the same version that you set in the previous step.
NetBeans  java.lang.UnsupportedClassVersionError: Unsupported major.minor version
If the version of compiler compliance level and Installed JRE is different, eclipse gives the messages as follows. "When selecting 1.8 compliance, make sure to have a compatible JRE installed and activated (currently 1.7)"

Android Studio

If you have installed Android N , change Android rendering version with older one and the problem will disappear.
android java.lang.UnsupportedClassVersionError: Unsupported major.minor version

NetBeans

If you're using the NetBeans IDE , right click on the project and choose Properties and go to sources, and you can change the Source/Binary Format to a lower JDK version. If you are using Maven , you can set the JDK version of each module by placing a file called nb-configuration.xml beside your pom.xml with the following content:
<?xml version="1.0" encoding="UTF-8"?> <project-shared-configuration> <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1"> <netbeans.hint.jdkPlatform>JDK_1.7</netbeans.hint.jdkPlatform> </properties> </project-shared-configuration>
The "JDK_1.7" Java platform must be configured in Tools -> Java Platforms -> Add Platform .