Why is it getting error using Java 11?
07:50:40,543 [main] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project product100.core: Fatal error compiling: invalid target release: 11 -> [Help 1]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
Solved! Go to Solution.
Views
Replies
Total Likes
Please check https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
Note: Merely setting the target
option does not guarantee that your code actually runs on a JRE with the specified version. The pitfall is unintended usage of APIs that only exist in later JREs which would make your code fail at runtime with a linkage error. To avoid this issue, you can either configure the compiler's boot classpath to match the target JRE, or use the Animal Sniffer Maven Plugin to verify your code doesn't use unintended APIs, or better yet use the release
option supported since JDK 9. In the same way, setting the source
option does not guarantee that your code actually compiles on a JDK with the specified version. To compile your code with a specific JDK version, different than the one used to launch Maven, refer to the Compile Using A Different JDK example.
Use release
option instead source
and target
Hi @jezwn ,
Please check if JAVA_HOME is set correctly.
Please also run the below command:
mvn --version
Check if maven is pointing the correct Java version.
Thanks,
Ishika B
This is AEM Cloud sandbox instance I'm talking about. It works fine locally.
Please check https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
Note: Merely setting the target
option does not guarantee that your code actually runs on a JRE with the specified version. The pitfall is unintended usage of APIs that only exist in later JREs which would make your code fail at runtime with a linkage error. To avoid this issue, you can either configure the compiler's boot classpath to match the target JRE, or use the Animal Sniffer Maven Plugin to verify your code doesn't use unintended APIs, or better yet use the release
option supported since JDK 9. In the same way, setting the source
option does not guarantee that your code actually compiles on a JDK with the specified version. To compile your code with a specific JDK version, different than the one used to launch Maven, refer to the Compile Using A Different JDK example.
Use release
option instead source
and target
Make sure that you are using java11 in the build pipeline, check the documentation at https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/using-...
Views
Likes
Replies