The java.lang.UnsupportedClassVersionError is a sub-class of LinkageError and ClassFormatError. The JVM (Java Virtual Machine) throw this error when try to read a file but Major and Minor Java version are not supported.
This Java Major and Minor class error occurred while running through IDE eclipse/STS or any because you JAVA_HOME or path or IDE Build Path is configured with different version of Java (JDK/JRE) however your code is compiled with different version of IDE. or Maven pom.xml is configured with different java version while running the program over different JDK/JRE which is not match with Major and Minor version supported.
In further post you will get to know about the resolution steps.
Example of Error Messages:
- Java
java.lang.LinkageError: XYZ has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
- Springboot
java.lang.UnsupportedClassVersionError: XYZ has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
- Maven
class file has wrong version 61.0, should be 55.0
Java Major Version
These are the Java Major Versions
Java | Major Version |
20 | 64 |
19 | 63 |
18 | 62 |
17 | 61 |
16 | 60 |
15 | 59 |
14 | 58 |
13 | 57 |
12 | 56 |
11 | 55 |
10 | 54 |
9 | 53 |
8 | 52 |
7 | 51 |
6 | 50 |
5 | 49 |
1.4 | 48 |
1.3 | 47 |
1.2 | 46 |
1.1 | 45 |
1.0.2 | 45 |
How to check Java Major Version?
Yu can run the below command in your command prompt.
javap -v <path to class file> | grep "major"
Example
$ javap -v build/classes/com/FacingIssuesOnIT/Book.class | grep “major”
How to fix Java Major and Minor Version Issue?
Follow these steps to resolve Java Major & Minor version issue:
Step 1: Go to command prompt and check for Java version

Step 2: In case your system is having more than one version of Java and you want to run your application or code with specific version, then go to Application-> Right click->Select Properties->Go to Build Path->Go to Library and remove the default Library from Class Path and Module Path.

Step 3: Click on Add Library Button and Select JRE System Library, click on Next button. If your JRE on default then select or go to alternate JRE and select Java path as below by Browse button. Click on Apply and Close button and then Finish button

Step 4: Now go to the left panel and select correct compiler version as below and click on apply button.

Step 5: If your application is Maven based then you have to make additional changes in your pom.xml also
Properties Section
<properties>
<java.version>20</java.version>
</properties>
Plugins Section
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>20</source>
<target>20</target>
</configuration>
</plugin>
</plugins>
Now save all your changes and run your application or program. It will work fine.
Reference
https://en.wikipedia.org/wiki/Java_class_file#General_layout
Conclusions
In this post you have learned about the Java Major and Minor version and also to check way of checking through command prompt. If you are facing such exceptions also provided way to resolve it.
Related Posts
Your Feedback Motivate Us
If our FacingIssuesOnIT Experts solutions guide you to resolve your issues and improve your knowledge. Please share your comments, like and subscribe to get notifications for our posts.
Happy Learning !!!
You must log in to post a comment.