错误:缺少JavaFX运行时组件-JavaFX 11和OpenJDK 11和Eclipse IDE

时间:2019-04-19 10:21:42

标签: java eclipse javafx javafx-11 gluon-desktop

我有一个经典的问题:将JavaFX 11与OpenJDK 11以及Eclipse IDE一起使用。

Error: JavaFX runtime components are missing, and are required to run this application

我有OpenJDK 11.0.2

dell@dell-pc:~$ java -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
dell@dell-pc:~$ 

我也有JavaFX 11 SDK。顺便说说!如果您想知道的话,我正在使用Lubuntu Linux 18.10。 enter image description here

然后,我将Eclipse IDE中.jar中的JavaFX 11 SDK个文件包含到库包中。

enter image description here

然后,我已将此库软件包包含在我的JAdaptiveMPC项目中。 enter image description here

我的代码语法没有错误,但是仍然无法编译我的项目。 enter image description here

你知道为什么吗?如果我从Maven导入所有这些.jar文件,而不是下载JavaFX SDK并将其导入库,则会出现相同的错误。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>Control</groupId>
  <artifactId>JAdaptiveMPC</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx</artifactId>
        <version>13-ea+5</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-base</artifactId>
        <version>13-ea+5</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>13-ea+5</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-graphics</artifactId>
        <version>13-ea+5</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-swing</artifactId>
        <version>13-ea+5</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-web</artifactId>
        <version>13-ea+5</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-media</artifactId>
        <version>13-ea+5</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>13-ea+5</version>
    </dependency>
  </dependencies>
</project>

继续

我已将其添加到Run Configuration

enter image description here

然后我尝试运行 enter image description here

仍然存在错误。

3 个答案:

答案 0 :(得分:1)

您的问题不是编译项目,而是运行它。 由于您的main是在您的Application扩展名中定义的,因此运行该项目将需要在启动时在模块路径中使用JavaFX。

因此,可以将main外包到与Application不同的类中,或者添加带有VM参数的JavaFX模块:

--module-path="<javafx-root>\lib" --add-modules="javafx.base,javafx.controls,..."

有关更多信息,请参见this

答案 1 :(得分:1)

这个问题很旧,但这是如何在intellij(linux)中为我工作的:

1-运行->编辑配置

2-在VM Options中添加路径:

-module-path yourpath / lib --add-modules javafx.controls,javafx.fxml

答案 2 :(得分:0)

enter image description here

在 eclipse 中,我从下拉列表中选择了这个 MODULE PATH 选项,它对我有用 - 我不需要 vm agruments。确保将 JavaFx jar 添加到依赖项选项卡(Eclipse >> 项目 >> 配置)下的 ModulePath 中