/errors/maven/source-option-5-is-no-longer-supported
Maven: Source option 5 is no longer supported. Use 7 or later.
- tool
- Maven
- exit code
- 1
- versions
- JDK 9+ with old maven-compiler-plugin defaults, Message varies by JDK: Use 7 or later / Use 8 or later
- os
- any
Source option 5 is no longer supported. Use 7 or later. comes from javac, called by Maven's compiler plugin: the build asked for Java 5 source level, which current JDKs cannot produce. Old versions of maven-compiler-plugin default to source and target 1.5 when the POM does not say otherwise. Set the Java version explicitly in pom.xml:
<properties>
<maven.compiler.release>17</maven.compiler.release>
</properties>In Maven's output the message appears as [ERROR] Source option 5 is no longer supported. Use 7 or later. (newer JDKs say Use 8 or later.), followed by the same line for the target option.
Reproduce it with javac
The message is javac's own, so javac with the same options produces it (JDK 17 here):
cat > App.java <<'EOF'
public class App { public static void main(String[] args) { System.out.println("ok"); } }
EOF
javac -source 5 -target 5 App.javaOutput · exit 2
warning: [options] bootstrap class path not set in conjunction with -source 5 error: Source option 5 is no longer supported. Use 7 or later. error: Target option 5 is no longer supported. Use 7 or later.
The lowest level a JDK accepts depends on its version, so the suggested minimum (Use 7 or later, Use 8 or later) changes with the JDK running Maven. The fix is the same: target a supported version.
cat > App.java <<'EOF'
public class App { public static void main(String[] args) { System.out.println("ok"); } }
EOF
javac --release 17 App.java && java AppOutput
ok
Fix in pom.xml
| Setting | Effect |
|---|---|
| <maven.compiler.release>17</maven.compiler.release> | Passes --release 17: language level, bytecode and JDK API checked against Java 17 (needs JDK 9+) |
| <maven.compiler.source>17</maven.compiler.source> + <maven.compiler.target>17</maven.compiler.target> | Older style: sets -source and -target, but does not stop you from using newer JDK APIs |
| <release>17</release> inside the maven-compiler-plugin configuration | Same as the property, scoped to the plugin |
Also pin a current plugin version so the defaults of very old versions are not used:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
</plugins>
</build>