Error Source option 5 is no longer supported Use 6 or later on Maven compile
27 September 2026 · 5 min read
Encountering the “Source option 5 is no longer supported. Use 6 or later” error during a Maven compile can be a frustrating roadblock for Java developers. This seemingly cryptic message points directly to a crucial incompatibility: your project is attempting to compile code using an outdated Java source version (specifically, Java 5 or 1.5) with a newer Java Development Kit (JDK) that no longer supports it. Modern JDKs, like Java 8, 11, or 17, have deprecated or removed support for very old source compatibility levels to ensure better performance, security, and the use of modern language features. Understanding the root cause and implementing the correct fixes is essential for a smooth build process, allowing you to move past this common Maven compile error and focus on your application’s logic rather than its build system.
Understanding the “Source Option 5” Error
The “Source option 5 is no longer supported. Use 6 or later” error message specifically indicates that the Java compiler, typically invoked by the Maven build process, is configured to accept source code written for Java 1.5 (which corresponds to source option 5). However, the JDK environment being used to compile the project is too new and has dropped support for this old version. Java’s evolution introduced significant changes and improvements over the years, leading to the deprecation of older syntax and features. When your compiler tries to build Java 5 code with a Java 8+ JDK, it flags this incompatibility, expecting at least Java 6 (source option 6) or a higher version.
This issue frequently arises when legacy projects are moved to newer build environments, or when developers upgrade their local JDK without updating their project’s pom.xml or other build configurations. The Maven compiler plugin is the primary culprit here, as it’s responsible for managing the source and target Java versions for your project. If its configuration is missing or incorrectly set, Maven defaults to an older version (often 1.5 or 1.6 in older Maven versions), leading to the “Source option 5 is no longer supported. Use 6 or later” message when a modern JDK is present. It’s a clear signal that your project’s Java compatibility settings need an update.
For instance, if your system’s JAVA_HOME points to JDK 17, but your pom.xml doesn’t explicitly declare a source and target version for the compiler plugin, Maven might implicitly attempt to compile for an older version, triggering this error. It’s crucial to align the project’s expected Java version with the capabilities of your installed Java Development Kit.
Diagnosing the Root Cause
Pinpointing the exact reason for the “Source option 5 is no longer supported. Use 6 or later” error requires checking a few key locations where your project’s Java version is defined or inferred. The most common culprits are your project’s pom.xml file, your system’s environment variables, and potentially your Integrated Development Environment (IDE) settings.
Examining Your pom.xml Configuration
The first place to look is your project’s pom.xml. This file dictates how Maven builds your project, and it’s where the Maven compiler plugin configuration is typically found. If the plugin isn’t explicitly configured, Maven might use a default source and target version that is too old for your current JDK. Look for the maven-compiler-plugin definition within the section. You should explicitly set the source and target properties to a modern Java version, such as 1.8 (Java 8), 11, or 17, depending on your project’s requirements and the JDK you intend to use. This ensures that the compiler arguments are correctly passed.
Consider a scenario where a project was initially developed with Java 5 and is now being compiled on a machine with JDK 11. Without updating the pom.xml, the build will fail. According to a report by Snyk, outdated dependencies and misconfigured build tools are common sources of security vulnerabilities and build failures in open-source projects, underscoring the importance of proper configuration management. Ensuring your target release aligns with your JDK version is paramount for avoiding build errors.
Checking Your System’s JAVA_HOME
Your system’s JAVA_HOME environment variable determines which Java Development Kit is used by default by your command line and build tools like Maven. If JAVA_HOME points to a very old JDK, or if it’s pointing to a JRE instead of a JDK, it can lead to compilation issues. Even if your pom.xml is configured correctly, an incorrect JAVA_HOME can cause conflicts. Verify that JAVA_HOME is set to the installation directory of a compatible JDK (e.g., C:\Program Files\Java\jdk-11 on Windows or /usr/lib/jvm/java-11-openjdk on Linux/macOS). You can check its value by running echo %JAVA_HOME% (Windows) or echo $JAVA_HOME (Linux/macOS) in your terminal.
Resolving the Error: Step-by-Step Guide
Resolving the “Source option 5 is no longer supported. Use 6 or later” error typically involves updating your Maven project’s configuration to specify a compatible Java source and target version. Follow these steps to rectify the issue:
Update the maven-compiler-plugin in pom.xml: This is the most common and effective solution. Open your project’s pom.xml file. Locate the section. If it doesn’t exist, create it. Inside , add or modify the section to include the maven-compiler-plugin configuration. ```
org.apache.maven.pluginsmaven-compiler-plugin3.8.11.81.8
Set both <source> and <target> to a Java version supported by your installed **Question & Answer :**
I am getting the following error on `$ mvn compile`:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Sym360: Compilation failure: Compilation failure: [ERROR] Source option 5 is no longer supported. Use 6 or later. [ERROR] Target option 1.5 is no longer supported. Use 1.6 or later. [ERROR] -> [Help 1]