Home > Java > javaTutorial > body text

How to Resolve Java 10/11 Maven Compilation Errors?

Mary-Kate Olsen
Release: 2024-11-17 19:50:02
Original
466 people have browsed it

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
Copy after login

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template