I am using Maven 3.5.0 and JDK 9 build 171. When I tried to compile my project I got an exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project admin: Fatal error compiling: ja-va.lang.NoClassDefFoundError: com/sun/tools/javac/file/BaseFileObject: com.sun.tools.javac.file.BaseFileObject
I added suggested flags to the MAVEN_OPTS but without success:
--add-opens jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
Any suggestions?
1 for LTS) requires Java 6 thus Maven jobs must be launched with a JDK >= 6. Jenkins >= 1.612 (1.625. 1 for LTS) requires Java 7 thus Maven jobs must be launched with a JDK >= 7.
The default Java compiler version used by Maven is Java 1.5 . Why that is still the default Java compiler version is a good question, since Java 5 was released in 2004.
You can't configure OpenJDK 11, you can configure maven to use java11, whether it will use Oracle Java or OpenJDK depends on which of the two is installed in your system and configured in your ide (or path, if you are using CLI). maven.apache.org/plugins/maven-compiler-plugin/examples/… You can't set it in the pom.
2.1. The Maven compiler accepts this command with –target and –source versions. If we want to use the Java 8 language features, the –source should be set to 1.8. Also, for the compiled classes to be compatible with JVM 1.8, the –target value should be 1.8. The default value for both of them is the 1.6 version.
Verify Java version used by Maven is correct.
Run mvn -v
this will show which java version maven is using.
For me, Maven was using Java 15, but my application was intended to run on Java 8. Setting JAVA_HOME to path for jdk8 fix the issue.
Upgrading the lombok version to 1.18.0 may fix your issue.
Check here. They fixed the issue in 1.18.0 version
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With