Specifying JDK 16 in Maven properties

Viewed 5599

I think this two lines specify JDK 11.

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

I am using Java FX 16 and I compile a code with JDK 16.

When I've tried specify JDK 16:

<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>

I get this error message:

Caused by: java.lang.module.InvalidModuleDescriptorException: Unsupported major.minor version 60.0

P.S. This is the pom.xml: https://pastebin.com/raw/qTe5Vtnq

P.P.S According to logs, I compile and run via /usr/lib/jvm/java-16-openjdk/bin/java.

2 Answers

Beyond JDK8, you need to specify the javac path of your JDK and you must set fork to true to get the code executed with mentioned compiler, in maven-compiler-plugin pom.xml file.

Here is the maven-compiler-plugin configuration,-

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <source>16</source>
        <target>16</target>
        <encoding>UTF-8</encoding>
        <fork>true</fork>
        <executable>C:\Progra~1\Java\jdk-16.0.2\bin\javac</executable>
    </configuration>
</plugin>
Related