Skip to content
Latchkey

Maven "invalid target release: 17" (JDK mismatch) in CI

javac cannot emit bytecode for a release newer than itself. The compiler-plugin asked for target 17 but the runner's JDK is older (for example 11), so the build fails immediately at compile.

What this error means

maven-compiler-plugin fails with "Fatal error compiling: invalid target release: 17". java -version on the runner shows a JDK older than the requested target.

mvn output
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project app:
Fatal error compiling: invalid target release: 17 -> [Help 1]

Common causes

The runner JDK is older than the target

A JDK 11 cannot target release 17. The project requests a newer bytecode level than the installed compiler supports.

JAVA_HOME points at the wrong JDK

Multiple JDKs are installed and JAVA_HOME resolves to an older one than the build needs.

How to fix it

Install a JDK at least as new as the target

Provision a JDK matching the requested release with setup-java.

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

Lower the target to match the available JDK

If you must build on an older JDK, reduce the requested release.

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

How to prevent it

  • Pin the runner JDK with setup-java to match <release>.
  • Verify java -version and JAVA_HOME early in the job.
  • Keep one source of truth for the Java version.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →