{"record":{"id":"9b081b7c211d3633","repo":"SonarSource/sonarqube","slug":"jdk-21-is-required-to-perform-this-build-it-s-cu","errorCode":null,"errorMessage":"JDK 21+ is required to perform this build. It's currently ${java.home}.","messagePattern":"JDK 21\\+ is required to perform this build\\. It's currently (.+?)\\.","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build.gradle","lineNumber":20,"sourceCode":"import org.sonar.build.BlackBoxTest\n\nimport static org.gradle.api.JavaVersion.VERSION_21\n\nplugins {\n  // Ordered alphabetically\n  id 'com.diffplug.spotless' version '8.10.1'\n  id 'com.gradleup.shadow' version '9.2.2' apply false\n  id 'com.google.protobuf' version '0.8.19' apply false\n  id 'com.jfrog.artifactory' version '6.0.4'\n  id 'com.ljarocki.parallel-zip' version '1.4.1' apply false\n  id \"de.undercouch.download\" version \"5.7.0\" apply false\n  id 'io.spring.dependency-management' version '1.1.7'\n  id \"org.cyclonedx.bom\" version \"3.4.1\" apply false\n  id 'org.sonarqube' version '7.4.0.8496'\n}\n\nif (!JavaVersion.current().isCompatibleWith(VERSION_21)) {\n  throw new GradleException(\"JDK 21+ is required to perform this build. It's currently \" + System.getProperty(\"java.home\") + \".\")\n}\n\n/**\n * The BOM related tasks are disabled by default, activated by:\n * - running in the CI and being on a main branch or a nightly build,\n * - or using '-Dbom' project property\n * - or by explicit call to 'cyclonedxBom' Gradle task\n */\n// Full-string regex (Groovy String.matches): must cover cyclonedxBom, cyclonedxDirectBom, and mergeCyclonedxBom.\ndef bomTasks = \"cyclonedx(Bom|DirectBom)|mergeCyclonedxBom\"\ndef ghBranch = System.getenv()[\"GITHUB_REF_NAME\"]\ndef isMainBranch = ghBranch in ['master'] || ghBranch ==~ 'branch-[\\\\d.]+'\n\nboolean enableBom = System.getenv('CI') == \"true\" && (isMainBranch) ||\n  System.getProperty(\"bom\") != null ||\n  gradle.startParameter.taskNames.findAll({ it.matches(\".*:($bomTasks)\") })\n\nallprojects {","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/build.gradle#L2-L38","documentation":"The root build.gradle enforces a minimum JDK version: if the JVM running Gradle (JavaVersion.current()) is not compatible with Java 21, the build fails fast with a GradleException before configuring projects. This guards use of Java 21 language features/toolchains required by the SonarQube build.","triggerScenarios":"Running ./gradlew (any task) with JAVA_HOME or the Gradle daemon JVM pointing to JDK 17, JDK 11, or any pre-21 runtime.","commonSituations":"Stale JAVA_HOME after upgrading JDKs; IDE (IntelliJ) Gradle JVM configured to an older JDK; Gradle daemon started under an old JVM and reused; CI runner image without JDK 21.","solutions":["Install JDK 21+ and set JAVA_HOME to it before running Gradle","Stop stale daemons with ./gradlew --stop so the new JVM is picked up","In IntelliJ, set Settings > Build Tools > Gradle > Gradle JVM to JDK 21","In CI, use a setup step (e.g. actions/setup-java with java-version: 21)"],"exampleFix":"// before\nexport JAVA_HOME=/usr/lib/jvm/java-17-openjdk\n// after\nexport JAVA_HOME=/usr/lib/jvm/java-21-openjdk\n./gradlew --stop && ./gradlew build","handlingStrategy":"validation","validationCode":"// shell: verify JDK before building\njava -version  # must be 21+\necho \"$JAVA_HOME\"  # must point to a JDK 21+ installation","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin JAVA_HOME to JDK 21 in your shell profile and CI workflow","Run ./gradlew --stop after switching JDKs to kill old daemons","Set the IDE Gradle JVM to JDK 21","Use a toolchain manager (sdkman, mise) to guarantee the right JDK"],"tags":["gradle","jdk","build","environment"],"backgroundTag":"incompatible-runtime-version","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}