Home › Java

Unsupported class file major version 65 (Java) — how to fix

BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 65
java.lang.IllegalArgumentException: Unsupported class file major version 61

Quick fix: Map the number to a Java version (52=8, 55=11, 61=17, 65=21, 69=25). Either run the build with an older JDK (export JAVA_HOME=/path/to/jdk-17, or set Gradle JDK in IntelliJ) or upgrade the tool: ./gradlew wrapper --gradle-version 8.10 (Java 21 needs Gradle 8.5+, Java 17 needs 7.3+). Upgrade ASM-based plugins too.

What it means

Every .class file starts with a major version that says which Java release produced it. Tools that parse bytecode (rather than the JVM running it) refuse versions newer than they know about.

Major Java
52 8
55 11
61 17
65 21
66 22
67 23
68 24
69 25

So major version 65 = something was compiled for/by Java 21, and the tool reading it predates Java 21 support.

This differs from UnsupportedClassVersionError (the JVM itself is too old to run the class); see UnsupportedClassVersionError.

Cause 1: Gradle is older than your JDK (most common)

BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' is Gradle's embedded Groovy failing because the JDK running Gradle is too new. Minimum Gradle per JDK:

JDK Gradle
17 7.3
21 8.5
23 8.10
25 9.1

Check and upgrade the wrapper:

./gradlew --version          # shows Gradle version and the JVM it runs on
./gradlew wrapper --gradle-version 8.10
./gradlew --version          # run twice to make sure the new version is used

If the old Gradle can't even start on your JDK, edit gradle/wrapper/gradle-wrapper.properties directly:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip

Cause 2: the build runs on a newer JDK than you think

Your project may target 17, but Gradle runs on whatever JAVA_HOME points to (or the IDE's setting).

To compile for a specific version independently of the JDK running Gradle, use a toolchain:

java {
    toolchain { languageVersion = JavaLanguageVersion.of(17) }
}

Cause 3: an old library or plugin with an old ASM

At runtime or during tests (Spring, Jacoco, Mockito/ByteBuddy, Spotbugs, Lombok, Shadow plugin), the stack trace shows org.objectweb.asm.ClassReader. Upgrade that component:

Cause 4: Maven

Maven itself doesn't hit this often, but plugins do (maven-shade-plugin, maven-surefire-plugin with old Jacoco). Update plugin versions and check mvn -v for the JDK Maven uses.

Quick check of a class file's version:

javap -v MyClass.class | grep major

Last updated 2026-11-24.