apache/iceberg · error · GradleException
This build must be run with JDK 17 or 21 but was executed wi
Error message
This build must be run with JDK 17 or 21 but was executed with JDK
What it means
Build-environment guard in build.gradle: the JVM running Gradle is neither JDK 17 nor JDK 21, which are the only supported versions for building this Iceberg checkout. The message reports the actual JDK; switch the launcher JVM (e.g. via JAVA_HOME or toolchains) and rerun.
Source
Thrown at build.gradle:78
"--add-opens", "java.base/java.math=ALL-UNNAMED",
"--add-opens", "java.base/java.net=ALL-UNNAMED",
"--add-opens", "java.base/java.nio=ALL-UNNAMED",
"--add-opens", "java.base/java.text=ALL-UNNAMED",
"--add-opens", "java.base/java.time=ALL-UNNAMED",
"--add-opens", "java.base/java.util.concurrent.atomic=ALL-UNNAMED",
"--add-opens", "java.base/java.util.concurrent=ALL-UNNAMED",
"--add-opens", "java.base/java.util.regex=ALL-UNNAMED",
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/jdk.internal.ref=ALL-UNNAMED",
"--add-opens", "java.base/jdk.internal.reflect=ALL-UNNAMED",
"--add-opens", "java.sql/java.sql=ALL-UNNAMED",
"--add-opens", "java.base/sun.util.calendar=ALL-UNNAMED",
"--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens", "java.base/sun.nio.cs=ALL-UNNAMED",
"--add-opens", "java.base/sun.security.action=ALL-UNNAMED",
"--add-opens", "java.base/sun.util.calendar=ALL-UNNAMED"]
} else {
throw new GradleException("This build must be run with JDK 17 or 21 but was executed with JDK " + JavaVersion.current())
}
tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
apply plugin: 'com.gorylenko.gradle-git-properties'
// git properties file for the root project for adding to the source tarball
gitProperties {
gitPropertiesName = 'iceberg-build.properties'
gitPropertiesResourceDir = file("${rootDir}/build")
extProperty = 'gitProps'
failOnNoGitDirectory = true
keys = ['git.branch', 'git.build.version', 'git.closest.tag.name','git.commit.id.abbrev', 'git.commit.id',
'git.commit.message.short', 'git.commit.time', 'git.tags']
version = projectVersion
}View on GitHub (pinned to 86d9c8fc54)
Solutions
- Set JAVA_HOME to a JDK 17 or 21 installation before running Gradle
- Configure the Gradle JVM in the IDE to JDK 17/21
- Use a toolchain/SDK manager (e.g. sdk, mise) to select the correct JDK
- Pin a JDK 17/21 in CI images
Example fix
// before export JAVA_HOME=/usr/lib/jvm/java-11-openjdk // after export JAVA_HOME=/usr/lib/jvm/java-17-openjdk && ./gradlew build
Defensive patterns
Strategy: validation
Validate before calling
if (!['17','21'].contains(JavaVersion.current().majorVersion)) {
println "Use JDK 17 or 21; found ${JavaVersion.current()}"
System.exit(1)
} Prevention
- Pin JAVA_HOME in shell profile and CI to JDK 17/21
- Set Gradle JVM in IDE project settings
- Use .sdkmanrc or similar to pin toolchain per repo
When it happens
Trigger: Running ./gradlew with JAVA_HOME pointing at JDK 8, 11, or a JDK newer than 21.
Common situations: Machine default JDK differs from project requirement; IDE Gradle JVM misconfigured; CI image with wrong Java toolchain.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- Neither version.txt nor git version exists:
- Releases must be built with Java 17
- The JMH benchmarks must be run with JDK 17 or JDK 21
- WARNING: Missing ${depsFile.name} in ${projectDir}. Run: ./g
- ============================================================
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/2e70f3fa3166fe7f.
Report an issue: GitHub.