java - 错误 : JavaFX runtime components are missing - JavaFX 11 and OpenJDK 11 and Eclipse IDE

标签 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

然后我包含了.jar来自 JavaFX 11 SDK 的文件在 Eclipse IDE 中放入一个库包中。

enter image description here

然后我将这个库包包含在我的JAdaptiveMPC 中。项目。
enter image description here

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

你知道为什么吗?如果我导入所有这些 .jar,我会遇到同样的错误来自 Maven 的文件,而不是下载 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

仍然错误。

最佳答案

您的问题不是编译项目,而是运行它。
由于您的main在您的 Application 中定义-extension,运行项目将需要在启动时模块路径中的 JavaFX。

所以要么外包你的main进入与您的Application 不同的类(class)或添加带有 VM 参数的 JavaFX 模块:

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

this了解更多信息。

关于java - 错误 : JavaFX runtime components are missing - JavaFX 11 and OpenJDK 11 and Eclipse IDE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55760343/

相关文章:

java - AWS CodeCommit 项目结构

java - 在 JavaFX 中让角色跳跃

java - 将代理群体移至顶层

java.lang.OutOfMemory错误: Java heap space on Payara and Eclipse

java - 带 where 子句的 Group By 的 Hibernate 标准

java - 使用不同的构建文件启动 java Eclipse headless 构建

java - 试图更改 setText() 方法的对齐方式?

java - 将 abel 包裹在复合 Material 中

java - 在 JavaFX 中使用新按钮动态更新 GridPane -> 如何重绘?

javafx - 如何在javafx中获取3D对象窗口上的2D坐标