Did you know?
On Ubuntu, the OpenJDK 21 and 25 JRE packages cannot compile with --release.
Ubuntu's openjdk-21/25 JRE packages lack ct.sym, so Maven builds with <release> fail with "release version N not supported" until you install the -jdk package.
- Programming
- Last checked
Explained
On Ubuntu and Debian, openjdk-21-jre-headless is only the runtime. It doesn’t include lib/ct.sym, the file javac --release uses to know each Java version’s APIs. So Maven can report Java version: 21 in mvn -v and still fail a project that sets <release>21</release> with error: release version 21 not supported.
We tested it on Ubuntu 26.04 with Maven 3.9.12: the build failed with only the JRE installed, and passed after sudo apt install openjdk-21-jdk-headless, with no other change. The 25 package has the same gap. The 11 and 17 JRE packages do include ct.sym, so they are not affected.
To check, run ls /usr/lib/jvm/java-21-openjdk-amd64/lib/ct.sym. If the file is missing, install the -jdk package.
Learn more
- How to Fix Maven Error: “Invalid target release: 21” Full guide · Updated Nov 2026
