Skip to content

Wrong Java version for the Minecraft version

Checked against Mojang’s version files and Gradle’s documentation on 2 November 2026.

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.

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.
  1. 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.release on JavaCompile to the same number. Keep both in step.

  2. 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.

  3. Or tell Gradle where your Java is. In gradle.properties, list folders with org.gradle.java.installations.paths (Gradle: custom toolchain locations).

  4. See what Gradle found:

    Terminal window
    ./gradlew -q javaToolchains

    It lists every Java Gradle detected, with its version and where it came from (Gradle: viewing toolchains).

  5. Check Gradle can handle that Java. Java 25 needs Gradle 9.1.0 or newer. See Gradle is too old for Java 25.

Linen installs the Java version a project needs. A folder with one version per subfolder works too: Linen sets each one up.