Skip to content
Latchkey

Maven "error: release version 17 not supported" - Fix JDK in CI

javac rejected the requested --release because the JDK compiling your code is older than that language level. A JDK 11 cannot emit release 17 - it has no knowledge of that version.

What this error means

Compilation aborts with error: release version 17 not supported. The number is the maven.compiler.release your POM requests; the JDK actually running is older than it.

mvn output
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile)
on project app: Compilation failure
[ERROR] error: release version 17 not supported

Diagnose it: resolve the effective POM first

Maven merges parent POMs, profiles, and settings before it builds anything. The configuration causing your failure is frequently inherited or activated by a profile that is on locally and off in CI.

Terminal
# the fully resolved configuration Maven will actually use
mvn help:effective-pom | head -60

# which profiles are active here vs on your machine?
mvn help:active-profiles

# full error, offline-safe, no colour codes to confuse the log
mvn -B -e -X <goal> 2>&1 | tail -60

Common causes

Runner JDK older than maven.compiler.release

CI defaulted to an older JDK (e.g. 11) while the POM sets <maven.compiler.release>17</maven.compiler.release>. The compiler does not support a release newer than itself.

JAVA_HOME resolves to the wrong JDK

Multiple JDKs are installed and JAVA_HOME (or PATH) points at the older one, so Maven compiles with it regardless of intent.

How to fix it

Provision the matching JDK

Set up the JDK your release targets and verify Maven uses it.

.github/workflows/ci.yml
- uses: actions/setup-java@v4
  with:
    distribution: temurin
    java-version: '17'
- run: mvn -B -version

Lower the release to fit the JDK

If you cannot upgrade, set the release no higher than the running JDK.

pom.xml
<properties>
  <maven.compiler.release>11</maven.compiler.release>
</properties>

How to prevent it

  • Pin the JDK with setup-java, assert it with mvn -version, and keep maven.compiler.release no higher than the provisioned JDK.

Frequently asked questions

What causes Maven "error: release version 17 not supported"?
There are 2 common causes: runner jdk older than maven.compiler.release and java_home resolves to the wrong jdk. CI defaulted to an older JDK (e.g.
How do I fix Maven "error: release version 17 not supported"?
There are 2 fixes depending on which cause you have: provision the matching jdk and lower the release to fit the jdk. Work through them in order, since the first is the most common.
What does Maven "error: release version 17 not supported" actually mean?
Compilation aborts with error: release version 17 not supported.
How do I stop Maven "error: release version 17 not supported" happening again?
Pin the JDK with setup-java, assert it with mvn -version, and keep maven.compiler.release no higher than the provisioned JDK.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card