Home >Java >javaTutorial >How to Resolve Java 10/11 Maven Compilation Errors?
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.
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!