我认为这两行指定了 JDK 11。
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
我正在使用 Java FX 16,并使用 JDK 16 编译代码。
当我尝试指定 JDK 16 时:
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
我收到此错误消息:
Caused by: java.lang.module.InvalidModuleDescriptorException: Unsupported major.minor version 60.0
附注这是
pom.xml
:https://pastebin.com/raw/qTe5Vtnq
P.P.S 根据日志,我通过
/usr/lib/jvm/java-16-openjdk/bin/java
编译并运行。
看起来像是一个错误。
https://github.com/openjfx/javafx-maven-plugin/issues/125
添加
<executable></executable>
和 JDK 16 的绝对路径应该可以修复它。
将你想要的版本的JDK bin目录放在你的路径上。
超越 JDK8,您需要指定 JDK 的
javac
路径,并且必须将 fork
设置为 true
才能使用上述编译器执行代码,在 maven-compiler-plugin
pom.xml
文件中。
这是maven-compiler-plugin配置,-
<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>