Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Maven fails with Fatal error compiling: release version not supported

ErrorFatal error compiling: error: release version 11 not supported

Short answer

The release option only works when Maven runs on a JDK that knows that Java version. The error means the JDK running Maven is older than the release you asked for, or is a JDK 8, which has no release option at all. Print mvn -version, then point JAVA_HOME at a newer JDK or fix the pom.

  • Applies to Maven 3.9, maven-compiler-plugin 3.13+, JDK 17, JDK 21, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Maven prints the JDK it runs on. Compare that version with the release number in your pom.

    mvn -version
    grep -n -E "release|maven.compiler" pom.xml
  2. 2Match what you see, then jump to its fix

    1. 1mvn -version shows a Java version lower than the number in maven.compiler.release (for example Java 8 with release 11), often on a CI runner or a shell with an old JAVA_HOMEMaven runs on a JDK older than the release you setFix
    2. 2Maven runs on Java 8 and the pom sets release (or maven.compiler.release)The release option is used on JDK 8Fix
    3. 3release is set to something like 1.8 instead of 8The release value is written in the old 1.x styleFix

What does the error look like?

  • Fatal error compiling: error: release version 11 not supported
  • Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:compile (default-compile)

Cause 1 of 3

Maven runs on a JDK older than the release you set

1Check

The compiler can target the JDK in use plus a limited number of earlier releases, so asking an old JDK for a newer release fails. Look at which JDK the shell and the CI image select.

echo "$JAVA_HOME"
java -version
mvn -version

2Fix

Install a JDK at least as new as the release and make Maven use it by setting JAVA_HOME for the build.

export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
export PATH="$JAVA_HOME/bin:$PATH"

3Verify

mvn -version now reports the new JDK and the build compiles.

mvn -version
mvn -q clean compile

Confirmed by maven.apache.org

Did this fix it?

Cause 2 of 3

The release option is used on JDK 8

1Check

The release option requires JDK 9 or later; javac in JDK 8 does not have it. If you must keep building on JDK 8 as well, the option has to be switched on only for newer JDKs.

mvn -version | head -n 3

2Fix

With maven-compiler-plugin 3.13.0 or newer, set source and target next to release; on JDK 8 the plugin uses those two instead. With an older plugin, set the release property only in a profile that activates on JDK 9 and above.

<configuration>
  <release>8</release>
  <source>8</source>
  <target>8</target>
</configuration>

<profile>
  <id>set-compiler-release</id>
  <activation>
    <jdk>[9,)</jdk>
  </activation>
  <properties>
    <maven.compiler.release>8</maven.compiler.release>
  </properties>
</profile>

3Verify

Build once on JDK 8 and once on a newer JDK; both compile.

mvn -q clean compile

Confirmed by maven.apache.org

Did this fix it?

Cause 3 of 3

The release value is written in the old 1.x style

1Check

The plugin guide uses the JEP 223 version scheme for release values.

grep -n -E "<release>|maven.compiler.release" pom.xml

2Fix

Write the plain number: 8, 11, 17, 21.

<properties>
  <maven.compiler.release>17</maven.compiler.release>
</properties>

3Verify

The compile goal runs without the release error.

mvn -q clean compile

Confirmed by maven.apache.org

Did this fix it?

How do I stop it coming back?

  • Pin the JDK in CI (for example with the runner's setup-java step) instead of relying on whatever the image ships.
  • Print mvn -version at the top of every CI build log.
  • Keep one release number in the maven.compiler.release property, not in several places.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.