Why this error?
The "Unsupported major.minor version 65" occurs when your Java code has been compiled with Java JDK version 21 (the latest LTS version) and you are currently trying to run this code (bytecode to be precise) on a Java version that lower than Java 21.
You can check your installed Java version by running the command java -version on Terminal.
How to fix this error?
There are two ways to fix this issue.
Option 1:
You can update your Java version installed on your device to Java 21.
Option 2:
If the code is yours, you will need to recompile your Java code with a target Java version that is compatible with the Java version installed on your device.
Say you are on Java version 17, then you will need to compile your code again in the following way using the javac compiler command.
javac -source 17 -target 17 MyClass.java
If you are working with a project in Eclipse, IntelliJ, or VS Code IDE, then make sure to update your build files to use the target as your installed Java version as follows.
Maven: pom.xml
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
Gradle: build.gradle
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
Facing issues? Have Questions? Post them here! I am happy to answer!
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
- Installing Java JDK 21 Final Release Candidate
- Steps to Install Java 21 (LTS JDK) on Windows 11
- How to install and Use Java JDK 21 Initial Release Candidate
- How to Enable Java JDK 21 Preview Features on IntelliJ
- Setting Up VS Code with Java JDK 21
- Java JDK 21 LTS Version Release Date (General Availability)
- [JEP 430] Java JDK 21 New Feature - String Templates (Preview)
- How to use Java JDK 21 with IntelliJ
- Java JDK 21: JEP 439 - An Improved Generational Z Garbage Collector (ZGC)
- [JEP 431] Java JDK 21 New Feature - Sequenced Collections
- Java JDK 21 - The Latest LTS Version
- Java JDK 21 - JEP 440 - Record Patterns
- Fix - Unsupported major.minor version 65.0 (Java JDK 21)
- How to get SharePoint Online user details from person or group column using REST API - SharePoint
- 31: Python Program to reverse a String - Python
- Let us try to answer why we need Genetics in Java? - Java
- Fix: error: mismatched closing delimiter } [Rust] - Rust
- Excel Fix: SECURITY RISK Microsoft has blocked macros from running because the source of this file is untrusted. - JavaScript
- Understanding AWS Calculator: DynamoDB on-demand capacity - AWS
- JDBCTemplate Querying Examples with Spring Boot 3 - Java
- Sort a List using Java 8 Stream Examples - Java