You are currently viewing How to Fix JAVA Error: Release Version Not Supported

How to Fix JAVA Error: Release Version Not Supported

Java Error: Release Version Not Supported

Problem Overview

When troubleshooting the error “Java release version not supported,” it’s essential to understand the context and potential solutions. This error typically occurs when Java application targets a specific Java version that is incompatible with the installed Java runtime environment, specially when  running multiple versions of JAVA and generally occurs during compiling process.

A quick recommendation is to review JAVA and it’s complier version, review of integration/build tool version such as MAVEN or JENKINS,  their compatibility with JAVA version on the machine. Look at ~/.bashrc, JAVA_HOME, POM.XML. In a mismatch or incompatibility scenario, JAVA complier will likely throw exceptions such as:

Error: Java release version 11 is not supported.
ERROR: Failed to execute goal org.apache.maven.plugins.maven-compiler-plugin:3.8.1:compile (default-compile) on project 
Fatal error compiling: error: release version 17 not supported
Fatal error compiling: error: release version 21 ot supported
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) 
on project Project-ID: Fatal error compiling: invalid target release: 21 -> [Help 1]
Java Error: Release Version Not Supported
Java Error: Release Version Not Supported

Troubleshooting Steps

Troubleshooting this error can be exhausting process as there are so many trigger points. Hence it’s important to review environment setup and application configuration:

First check if there is any version upgrade of any application component such as JAVA, Jenkins or Maven etc. Review JAVA and JAVAC versions:

$ which java ; which javac ; java -version ; javac -version ; mvn -v

Review your Application Configuration Environment Variables. On Linux OS, carefully review ~/.bashrc. Make sure JAVA_HOME is set correctly. Post JAVA, JENKINS or MAVEN upgrade, version location might be changed. In such cases, environment variables, PATH may need to be changed  accordingly.
Remember, a latest version of MAVEN or JENKINS may not work with older version of JAVA due to lack of backward compatibility. Similarly a latest version of JAVA may not work well with older version of MAVEN or JENKINS.

Expert Pro Tip

Sometime developers update their JAVA version but fail to look at version of JAVA compiler. Make sure you verify JAVA and JAVA complier are same. This is important if you are working in RedHat (RHEL) or similar Linux flavours.

Make sure you are running same version of JAVA and JAVAC compiler:

$ java -version
$ javac -version

Select the correct JAVA and JAVAC versions (if multiple version available):

$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac

On RHEL type flavours of Linux, JAVAC may not be available as it comes bundled in devel packages. Make sure with JAVA, JAVAC is also installed with correct version. For example if you are running JAVA 17, JAVA 17 compiler should be installed by running this command:

$ sudo yum install java-17-openjdk-devel

Once done, set JDK installation directory, JAVA_HOME according to selected JAVA complier:

$ export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")

Quick reminder for MAVEN Users

If you are using integration or build tools such as JENKINS or MAVEN make sure they are compatible with the JAVA version running on your system. Specially cross check MAVEN compiler plugin compatibility with JAVA.

Also review your pom.xml file and make sure correct JAVA version is being used. Ultimately, your JAVA_HOME version and the JAVA version mentioned in pom.xml should match.

Conclusion

Hope this quick troubleshooting guide helps you resolve Java Release Version Not Supported error. Consider switching to a supported version (e.g., Java 11 or Java 17) based on your project requirements.  Remember to consult the official Java documentation for comprehensive guidance on Java development, best practices, and troubleshooting. Feel free to ask in comment section or reach out if you need further assistance! 😊

📩 Stay ahead with expert insights on JavaScript, DevOps, and SRE trends.

💼 Interested in collaborations, partnerships, or sponsorships? Let’s connect! 🚀

Spread the love

team_cicdtrail

Only for Editorials, blogs and articles.

This Post Has One Comment

  1. raj

    Best blogs on this error

Leave a Reply