Resolving Java Version Compatibility Error in IntelliJ IDEA: release version 5 not supported

Nov 17, 2025 · Programming · 11 views · 7.8

Keywords: IntelliJ IDEA | Java Compilation Error | Maven Configuration | Version Compatibility | JavaFX Dependencies

Abstract: This article provides an in-depth analysis of the common Java compilation error 'Error:java: error: release version 5 not supported' in IntelliJ IDEA. Through configuring Maven project compiler versions, adjusting IntelliJ IDEA project settings, and properly handling JavaFX dependencies, developers can quickly identify and resolve version compatibility issues. The article combines specific error scenarios to provide comprehensive guidance from project configuration to environment setup.

Problem Background and Error Analysis

When using IntelliJ IDEA Ultimate 2019.3.1 to develop Java Maven projects, many developers encounter the compilation error: Error:java: error: release version 5 not supported. This error typically occurs when attempting to run simple Java projects, where even basic Hello World programs fail to compile properly.

From the error message, it's evident that the root cause lies in Java compilation version incompatibility. When developers use the OpenJDK 11.0.5 environment, the system's default compilation target version is set to Java 5, while modern JDK versions no longer support such outdated Java versions.

Environment Configuration Verification

First, verify the Java version configuration of the development environment. Execute java --version and javac --version commands via terminal to confirm that OpenJDK 11.0.5 is currently in use. This indicates that the development environment itself supports newer Java features, with the problem stemming from mismatched project configuration and compilation environment.

In IntelliJ IDEA's Java compiler settings, if the "Target bytecode version" is set to 1.5 or lower, version unsupported errors will occur. When attempting to modify it to 1.8, JavaFX-related dependency errors may appear:

Error:(1, 26) java: package javafx.application does not exist
Error:(2, 20) java: package javafx.stage does not exist
Error:(4, 27) java: cannot find symbol
  symbol: class Application
Error:(12, 23) java: cannot find symbol
  symbol:   class Stage
  location: class Main
Error:(7, 9) java: cannot find symbol
  symbol:   method launch(java.lang.String[])
  location: class Main
Error:(11, 5) java: method does not override or implement a method from a supertype

These errors indicate that the JavaFX module has been removed from Java 11 and requires separate dependency configuration.

Maven Project Configuration Solution

For Maven projects, the fundamental solution is to explicitly specify the compiler version in the pom.xml file. Maven defaults to using Java 1.5 as the compilation target, which causes compatibility issues with newer JDK versions.

Add the following configuration to the <properties> section in pom.xml:

<properties>
  <maven.compiler.source>1.8</maven.compiler.source>
  <maven.compiler.target>1.8</maven.compiler.target>
</properties>

Additionally, ensure the project includes the correct version of maven-compiler-plugin:

<dependency>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.8.1</version>
</dependency>

This configuration approach ensures Maven uses the specified Java version during compilation, avoiding issues with default versions being too low.

IntelliJ IDEA Environment Configuration

Beyond Maven configuration, corresponding environment settings need to be adjusted in IntelliJ IDEA:

  1. Via the File → Project Structure → Project menu:
    • Set Project SDK to 11
    • Set Project language level to 11
  2. Set language level to 11 in File → Project Structure → Modules → Sources
  3. Open settings with Ctrl+Alt+S, navigate to Build, Execution, Deployment → Compiler → Java Compiler:
    • Set Project bytecode version to 11
    • Set version to 11 at the Module level

JavaFX Dependency Handling

For projects using JavaFX, separate dependency handling is required in Java 11 and later versions. JavaFX was removed from the JDK starting with Java 11 and needs to be introduced as an external dependency.

Add JavaFX dependency in pom.xml:

<dependency>
  <groupId>org.openjfx</groupId>
  <artifactId>javafx-controls</artifactId>
  <version>11.0.2</version>
</dependency>

Additionally, add JavaFX module path parameters to the run configuration to ensure JavaFX loads correctly.

Verification and Testing

After completing the above configurations, rebuild the project and run tests. If configured correctly, compilation errors should disappear, and the project should start normally. Create a simple test class to verify if the configuration is effective:

public class TestConfiguration {
    public static void main(String[] args) {
        System.out.println("Java Version: " + System.getProperty("java.version"));
        System.out.println("Compilation Test Successful");
    }
}

If this test class compiles and runs normally, it indicates that version configuration issues have been resolved.

Summary and Best Practices

The key to resolving the release version 5 not supported error lies in ensuring consistency between project configuration and development environment. It's recommended to explicitly specify Java versions when creating new projects, avoiding default configurations. For team development projects, compiler versions should be uniformly configured in pom.xml to ensure all developers use the same compilation environment.

Additionally, regularly updating development tools and dependency library versions, maintaining compatibility with the latest Java versions, can effectively prevent similar version compatibility issues. For projects using specific modules like JavaFX, pay special attention to changes brought by modularization and adjust project configurations promptly.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.