You Cannot Run Gradle 8.4 on Java 21 — Here's Why
Note: This blog post was enhanced with the help of AI to improve grammar and refine tone. All content and opinions are my own.
Ah, the promise of Java 21 — new features, shiny optimizations, and that irresistible urge to upgrade all the things. So naturally, you install Java 21, update your Gradle to 8.4 (which proudly announces Java 21 support), and run your build.
And then… 💥 Boom. Gradle faceplants.
Wait, Isn’t Gradle 8.4 Supposed to Support Java 21?
Yes — but not quite the way you think.
According to Gradle 8.4 release notes, it can compile, test, and run Java programs targeting Java 21. That’s fantastic.
But what it can’t do — at least not yet — is run itself on Java 21. And that little footnote can derail your whole day if you’re not paying close attention.
Who’s the Culprit?
Let’s point fingers: 🫵 Kotlin.
Gradle heavily relies on Kotlin, especially because Kotlin DSL has become the default for build scripts. And Kotlin, lovely as it is, didn’t support Java 21 until version 1.9.20.
Unfortunately, Gradle 8.4 is still shipping with an older version of Kotlin that doesn’t play nice with Java 21. So even if your own project is ready for the future, Gradle’s internal Kotlin bits are still living in the past.
Is There a Fix?
Update (September 2025): Yes! This issue has been completely resolved.
The fix I mentioned was indeed implemented, and modern Gradle versions (8.5+ and especially 8.8+) now fully support running on Java 21. Kotlin has also been updated to support Java 21 properly.
✅ Current Recommendations
- Gradle 8.8+ with Java 21 works perfectly
- Kotlin 1.9.20+ fully supports Java 21 (current versions are much newer)
- No more workarounds needed — upgrade both and you’re good to go
Historical Context (What This Post Was About)
Back in November 2023, this was a real pain point that caught many developers off-guard. The core issue was:
- Gradle 8.4 could build Java 21 projects but couldn’t run on Java 21 itself
- The limitation came from bundled Kotlin versions that predated Java 21 support
- Developers had to run Gradle on Java 17/20 while targeting Java 21
TL;DR
- Then (2023): Gradle 8.4 + Java 21 = 💥
- Now (2025): Gradle 8.8+ + Java 21 = ✅
- If you’re still on old versions, just upgrade both Gradle and Kotlin
Gradle: “I’m ready for Java 21!”
Also Gradle: “But only on the outside…”
If you’re like me and love breaking things just to see what happens, you’ll understand the pain. Until then — happy building!