Fix java.lang.UnsupportedClassVersionError in Eclipse

Usually people who’ve installed Eclipse newly receive this error. Let us understand the meaning of this Error. This error gets thrown when JVM tries to run a class file and finds that the JRE version is not within the min and max versions mentioned in the class file.

But why this happens?

It could be possible that, you’ve updated the JRE home to the desired JRE installed on your PC. In the below Preferences screen you can see that the JRE location is set to JDK 1.8 path installed in Program Files folder.

However, you may have forgotten to change the default Compiler compliance level. In the below screen, you can see that the Compiler compliance level is set to JDK 15.

Changing this version to JDK 1.8 will resolve the java.lang.UnsupportedClassVersionError.

To do that, navigate to this screen as follows:

  1. Select Window >> Preferences, eclipse preferences dialog box gets opened
  2. From the left navigation, Select Java >> Compiler
  3. Change Compiler compliance level to the same JDK version that of the JRE.