Home >Java >javaTutorial >How to Resolve Java 10/11 Maven Compilation Errors?

How to Resolve Java 10/11 Maven Compilation Errors?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-17 19:50:02532browse

How to Resolve Java 10/11 Maven Compilation Errors?

Compiling Java 10 / Java 11 Projects with Maven

Error: Inability to Compile

When attempting to compile a simple Java 10 or Java 11 project using Maven, users may encounter the following error:

java.lang.IllegalArgumentException

This error stems from the incompatibility between the project's Java version and the version specified in the Maven plugin configuration.

Resolution

To resolve this issue and enable compilation with Java 10 or Java 11, update the Maven plugin configuration as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <release>10</release>  <!-- or release 11 -->
    </configuration>
</plugin>

Note: This update introduces the maven-compiler-3.8.0 plugin and specifies the release parameter to match the desired Java version (10 or 11).

As of the latest version of the plugin (3.8.0), you can use it to compile against JDK/12 as well. Comprehensive details and a sample configuration for compiling with JDK/12 are available in the linked article "Compile and execute a JDK preview feature with Maven."

The above is the detailed content of How to Resolve Java 10/11 Maven Compilation Errors?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn