{"record":{"id":"d156d39f301512e7","repo":"Anuken/Mindustry","slug":"you-must-use-java-17-or-above-to-compile-and-r","errorCode":null,"errorMessage":"!!! YOU MUST USE JAVA 17 OR ABOVE TO COMPILE AND RUN MINDUSTRY !!! Read the README. Your version: ${System.properties[\"java.version\"]}","messagePattern":"!!! YOU MUST USE JAVA 17 OR ABOVE TO COMPILE AND RUN MINDUSTRY !!! Read the README\\. Your version: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"settings.gradle","lineNumber":2,"sourceCode":"if(JavaVersion.current().ordinal() < JavaVersion.VERSION_17.ordinal()){\n    throw new Exception(\"!!! YOU MUST USE JAVA 17 OR ABOVE TO COMPILE AND RUN MINDUSTRY !!! Read the README. Your version: ${System.properties[\"java.version\"]}\")\n}\n\ninclude 'desktop', 'core', 'server', 'ios', 'annotations', 'tools', 'tests'\n\ndef hasSdk = System.getenv(\"ANDROID_HOME\") != null\n\ndef localProperties = new Properties()\nif(new File(settingsDir, 'local.properties').exists()){\n    localProperties.load(new File(settingsDir, 'local.properties').newDataInputStream())\n\tif(localProperties.containsKey(\"sdk.dir\")) hasSdk = true\n}\n\nif(System.getenv(\"JITPACK\") == \"true\") hasSdk = false\n\nif(hasSdk){\n    include 'android'\n}else{\n    println(\"No Android SDK found. Skipping Android module.\")","sourceCodeStart":1,"sourceCodeEnd":20,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/settings.gradle#L1-L20","documentation":"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.","triggerScenarios":"Running any gradle task (build, run, test) with JAVA_HOME or PATH pointing at JDK 8, 11, or any pre-17 JDK.","commonSituations":"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.","solutions":["Install JDK 17 (or newer) and point JAVA_HOME at it, then re-run.","Configure the gradle toolchain in the build to auto-provision JDK 17 regardless of the system default.","Update the CI Docker image to one shipping JDK 17+.","In the IDE, set the Project SDK and the gradle JVM to JDK 17 or above."],"exampleFix":"// before: settings.gradle top-level guard only\nif(JavaVersion.current().ordinal() < JavaGradleVersion.VERSION_17.ordinal()) throw new Exception(...)\n\n// after: also let gradle auto-select the toolchain in build.gradle so the system default no longer matters\njava {\n    toolchain {\n        languageVersion = JavaLanguageVersion.of(17)\n    }\n}","handlingStrategy":"validation","validationCode":"// Verify toolchain before invoking gradle\nString ver = System.getProperty(\"java.version\");\nif(Runtime.version().feature() < 17){\n    throw new IllegalStateException(\"JDK 17+ required, found \" + ver);\n}","typeGuard":"static boolean isJdk17OrAbove(){\n    return Runtime.version().feature() >= 17;\n}","tryCatchPattern":null,"preventionTips":["Set JAVA_HOME to a JDK 17+ installation and verify with 'java -version'.","Pin CI images to a JDK 17+ base and fail fast if the wrong JDK is detected.","Configure the gradle toolchain (JavaLanguageVersion.of(17)) so the system default no longer matters.","In the IDE, set both the Project SDK and the Gradle JVM to JDK 17 or above."],"tags":["build","java","version","environment","gradle"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}