Anuken/Mindustry · critical · Exception

!!! YOU MUST USE JAVA 17 OR ABOVE TO COMPILE AND RUN MINDUST

Error message

!!! YOU MUST USE JAVA 17 OR ABOVE TO COMPILE AND RUN MINDUSTRY !!! Read the README. Your version: ${System.properties["java.version"]}

What it means

Thrown at the top of settings.gradle when the running JDK is older than Java 17. The check compares JavaVersion.current().ordinal() against VERSION_17's ordinal and throws before any project is configured, so the build fails fast with an unambiguous message. Mindustry targets JDK 17 bytecode and APIs, so an older toolchain cannot compile or run it.

Source

Thrown at settings.gradle:2

if(JavaVersion.current().ordinal() < JavaVersion.VERSION_17.ordinal()){
    throw new Exception("!!! YOU MUST USE JAVA 17 OR ABOVE TO COMPILE AND RUN MINDUSTRY !!! Read the README. Your version: ${System.properties["java.version"]}")
}

include 'desktop', 'core', 'server', 'ios', 'annotations', 'tools', 'tests'

def hasSdk = System.getenv("ANDROID_HOME") != null

def localProperties = new Properties()
if(new File(settingsDir, 'local.properties').exists()){
    localProperties.load(new File(settingsDir, 'local.properties').newDataInputStream())
	if(localProperties.containsKey("sdk.dir")) hasSdk = true
}

if(System.getenv("JITPACK") == "true") hasSdk = false

if(hasSdk){
    include 'android'
}else{
    println("No Android SDK found. Skipping Android module.")

View on GitHub (pinned to f695ad7e60)

Solutions

  1. Install JDK 17 (or newer) and point JAVA_HOME at it, then re-run.
  2. Configure the gradle toolchain in the build to auto-provision JDK 17 regardless of the system default.
  3. Update the CI Docker image to one shipping JDK 17+.
  4. In the IDE, set the Project SDK and the gradle JVM to JDK 17 or above.

Example fix

// before: settings.gradle top-level guard only
if(JavaVersion.current().ordinal() < JavaGradleVersion.VERSION_17.ordinal()) throw new Exception(...)

// after: also let gradle auto-select the toolchain in build.gradle so the system default no longer matters
java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}
Defensive patterns

Strategy: validation

Validate before calling

// Verify toolchain before invoking gradle
String ver = System.getProperty("java.version");
if(Runtime.version().feature() < 17){
    throw new IllegalStateException("JDK 17+ required, found " + ver);
}

Type guard

static boolean isJdk17OrAbove(){
    return Runtime.version().feature() >= 17;
}

Prevention

When it happens

Trigger: Running any gradle task (build, run, test) with JAVA_HOME or PATH pointing at JDK 8, 11, or any pre-17 JDK.

Common situations: CI image pinned to an old JDK; a machine with multiple JDKs where the default is pre-17; an IDE configured with a too-old project SDK; a fresh checkout on a system whose default java is legacy.

Related errors


AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14). Data as JSON: /api/errors/d156d39f301512e7. Report an issue: GitHub.