我知道这个问题已经被问了多次……但是我似乎找不到解决方案。
以下内容取自官方指南示例:https://openjfx.io/openjfx-docs/#gradle 我继续添加到我的build.gradle:
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.8'
}
javafx {
version = '13'
modules = ['javafx.controls']
}
repositories {
mavenCentral()
}
mainClassName = "MyImage"
jar {
manifest {
attributes "Main-Class": "$mainClassName"
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
通过运行gradle jar(或gradle build),应该会生成一个jar文件,其中包括它所构建的所有包,即整个javafx库。
然而,当它构建成功后,我继续运行:
java -jar build/libs/MyImage.jar
仍然会抛出错误:
Error: JavaFX runtime components are missing, and are required to run this application
我错过了什么?
(我使用JDK 11)
非常感谢。