Fix - Unsupported major.minor version 65.0 (Java JDK 21)

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

    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


    Gradle: build.gradle

    java {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
Fix - Unsupported major.minor version 65.0

This is not an AI-generated article but is demonstrated by a human on an M1 Mac running Java JDK 21 and 17.

Please support independent contributors like Code2care by donating a coffee.

Buy me a coffee!

Buy Code2care a Coffee!

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

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:

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap