Wrong Java version for the Minecraft version
Checked against Mojang’s version files and Gradle’s documentation on 2 November 2026.
Which Java each version needs
Section titled “Which Java each version needs”Mojang’s version files list the Java each version runs on (javaVersion.majorVersion in each version’s JSON, linked from
the version manifest):
| Minecraft | Java |
|---|---|
| 1.12.2 – 1.16.5 | 8 |
| 1.17 – 1.17.1 | 16 |
| 1.18 – 1.20.4 | 17 |
| 1.20.5 – 1.21.11 | 21 |
| 26.1 and newer | 25 |
Your mod must compile for that Java. After you change a mod’s Minecraft version, change its Java too.
Two Javas
Section titled “Two Javas”A mod build uses two Javas, and they can differ:
- The Java your mod compiles for, set by the Java toolchain in
build.gradle. It should match the table above. - The Java that runs Gradle itself. Gradle 9 doesn’t run on Java 16 or older (Gradle compatibility matrix), and Fabric says 26.1 needs Java 25 for the Gradle JVM (Fabric, 14 March 2026). Linen’s Fabric templates, for example, run Gradle on Java 25 even for a Java 8 mod.
-
Set the toolchain in
build.gradle, with the number from the table (Gradle: Toolchains):java {toolchain {languageVersion = JavaLanguageVersion.of(25)}}Fabric’s templates also set
options.releaseonJavaCompileto the same number. Keep both in step. -
Let Gradle download a missing Java. Gradle only downloads a toolchain if a toolchain resolver plugin is applied. The Foojay plugin is one; put it in
settings.gradle(Gradle: auto-provisioning):plugins {id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'}NeoForge’s MDKs already have this line.
-
Or tell Gradle where your Java is. In
gradle.properties, list folders withorg.gradle.java.installations.paths(Gradle: custom toolchain locations). -
See what Gradle found:
Terminal window ./gradlew -q javaToolchainsIt lists every Java Gradle detected, with its version and where it came from (Gradle: viewing toolchains).
-
Check Gradle can handle that Java. Java 25 needs Gradle 9.1.0 or newer. See Gradle is too old for Java 25.
In Linen
Section titled “In Linen”Linen installs the Java version a project needs. A folder with one version per subfolder works too: Linen sets each one up.