Eclipse - Unsupported major.minor version 53.0, 52.00, 51.0 Error in Java

The UnsupportedClassVersionError is a big nightmare for Java developers, probably the next biggest after NoClassDefFoundError and ClassNotFoundException but its slightly easier to solve. The root cause of this error is that your code is compiled using higher JDK version and you are trying to run it on the lower version. For example, the Unsupported major.minor version 53.0 means your code is compiled in JDK 9 (the class version 52 corresponds to JDK 9) and you are trying to run it on any JRE lower than Java 9, probably JDK 8, 7, or 6.

Similarly, the Unsupported major.minor version 52.0 means your code is compiled using JDK 8 compiler and you are trying to run it on lower JVM e.g. JDK 7 or 7.

And, finally, the Unsupported major.minor version 51.0 means your code is compiled using JDK 7 and you are trying to run it on JRE 6 or 5.

This error will not occur if you compile in JDK 7 and running in JDK 8 because Java is backward compatible but it won't work otherwise because higher version generally has features which are not supported by lower version.

I have written how do deal with UnsupportedClassVersionError in past but today we'll focus on dealing with this error in Eclipse. For example, if you are running your program in Eclipse and getting this error than what should you do? Or how do you solve this error in Eclipse?

Before you solve this error you need to understand the Eclipse setup e.g. how your project or Java classes are compiled and how they are executed. When you create a project in Eclipse then you choose a JRE, which is used for both compilation and execution.

Btw, if you are new to Eclipse IDE then I suggest you to first go through Beginners Eclipse Java IDE Training Course to learn basic features of Eclipse IDE.

But, you can change the JRE for execution under run configuration and sometimes it also pick up the default JRE. That's where the problem occurs. If you are using JDK 8 in your project as shown below but if you are using any lower JRE under run configuration then you will get Unsupported major.minor version 52.0 Error in Eclipse.

In order to solve this error just use the JDK 8 or JDK 8 on Run configuration for your project as shown below:

Solving Unsupported major.minor version 53.0, 52.00, 51.0 Error

Now to understand this situation better, let's create this error and solve it. I have a Java project and a Java class and my project are configured to use the JDK 8 in build path as shown below:

Eclipse - Unsupported major.minor version 51.0 Error

Now, just compile and run the program which creates a run configuration for it automatically with right JRE version. The program will run fine.

Now, let's change the JRE version in the Eclipse Run Configuration:

Eclipse - Unsupported major.minor version 52.00 Error

Now, if you run the same program, this time it will throw Unsupported major.minor version 52.0 error:

java.lang.UnsupportedClassVersionError: Demo : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(
at java.lang.ClassLoader.defineClass(
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
Exception in thread "main"

Here is the screenshot from Eclipse IDE:

Eclipse - Unsupported major.minor version 53.0 Error

Bingo, this happens because now you are trying to run a Java program which is compiled at higher JDK into lower JRE. When you compile, class files are created which has major and minor version depending upon which javac is used to create them.

They can only run on the same version of JRE or the higher version of JRE. If you run them in the lower version they will throw this "java.lang.UnsupportedClassVersionError: Demo : Unsupported major.minor version 52.0" error.

In short:
1) If you get Unsupported major.minor version 53.0 Error then make sure you have JDK 9 under your run configuration in Eclipse.

2) If you get Unsupported major.minor version 52.0 Error then make sure you have JDK 8 under your run configuration in Eclipse.

3) If you get Unsupported major.minor version 51.0 Error then make sure you have JDK 7 on your run configuration in Eclipse.

That's all about how to solve the Unsupported major.minor version 53.0, 52.0, and 51.0 Error in Eclipse IDE. Just check which JRE or JDK you are using for compiling and running your Java program. You can check that inside your build path and run configuration. Make sure you use same or higher version of JRE to run your program then you used for compiling them. This will solve this error. If you want to learn more about Eclipse IDE itself, then go through  Beginners Eclipse Java IDE Training Course, one of the quick ways to learn Eclipse IDE.

Further Learning
The Complete Java MasterClass
Java Fundamentals Part 1 and Part 2
Java Interview Guide: 200+ Interview Questions

Other Java troubleshooting articles you may like:
  • java.sql.SQLException: No suitable driver found for 'jdbc:mysql://localhost:3306/mysql [Solution]
  • How to solve java.lang.ClassNotFoundException: com.mysql.jdbc.Driver error? (hint)
  • How to solve java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver? (solution)
  • java.sql.SQLServerException: The index 58 is out of range - JDBC (solution)
  • How to solve java.lang.OutOfMemoryError: Java Heap Space in Eclipse, Tomcat? (solution)
  • How to fix "Error: Could not find or load main class" in Eclipse? (guide)
  • How to avoid ConcurrentModificationException in Java? (tutorial)
  • How to fix Caused By: java.lang.NoClassDefFoundError: org/apache/log4j/Logger (solution)
  • How to fix 'javac' is not recognized as an internal or external command (solution)
  • How to connect to MySQL database in Java? (tutorial)
  • java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory error (solution)
  • Common reasons of java.lang.ArrayIndexOutOfBoundsException in Java? (solution)
  • java.lang.ClassNotFoundException : org.Springframework.Web.Context.ContextLoaderListener (solution)
  • Fixing java.lang.UnsupportedClassVersionError unsupported major.minor version 50.0 (solution)
  • How to solve "could not create the Java virtual machine" error in Java? (solution)
  • 10 common reasons for java.lang.NumberFormatException in Java? (tutorial)
  • How to fix "illegal start of expression" compile time error in Java? (tutorial)
  • Cause and solution of "class, interface, or enum expected" compiler error in Java? (fix)
  • How to solve "variable might not have initialized" compile-time error in Java? (answer)

Thanks for reading this article, if you like this article then please share with your friends and colleagues too. If you have any doubt or questions then please drop a comment.

No comments:

Post a Comment

Feel free to comment, ask questions if you have any doubt.