Maven fails with Fatal error compiling: release version not supported
Fatal error compiling: error: release version 11 not supportedShort 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.
Fix it fast
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.xml2Match what you see, then jump to its fix
- 1
mvn -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
Maven runs on Java 8 and the pom sets release (or maven.compiler.release)The release option is used on JDK 8Fix - 3
release is set to something like 1.8 instead of 8The release value is written in the old 1.x styleFix
- 1
What does the error look like?
Fatal error compiling: error: release version 11 not supportedFailed 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 -version2Fix
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 compileConfirmed by maven.apache.org
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 32Fix
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 compileConfirmed by maven.apache.org
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.xml2Fix
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 compileConfirmed by maven.apache.org
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 fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fixServers
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
Apache warns that a ${VAR} config variable is not defined
${VAR} left unchanged in the configuration, with a warning in the error log
Apache expands ${VAR} from Define or from the shell environment that exists when the server starts.
3 causes, each with a fix