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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/55760343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 01:13:16  来源:igfitidea点击:

Error: JavaFX runtime components are missing - JavaFX 11 and OpenJDK 11 and Eclipse IDE

javaeclipsejavafxjavafx-11gluon-desktop

提问by Daniel M?rtensson

I have this classical issue: Using JavaFX 11 with OpenJDK 11 together with Eclipse IDE.

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

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

I have OpenJDK 11.0.2

我有 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:~$ 

And I also have JavaFX 11 SDK. By the way! I'm using Lubuntu Linux 18.10 if you wonder. enter image description here

我也有JavaFX 11 SDK。顺便一提!如果您想知道,我正在使用 Lubuntu Linux 18.10。 在此处输入图片说明

Then I have included the .jarfiles from the JavaFX 11 SDKin Eclipse IDE into a library package.

然后我.jarJavaFX 11 SDKEclipse IDE 中的文件包含到一个库包中。

enter image description here

在此处输入图片说明

Then I have included this library package into my JAdaptiveMPCproject. enter image description here

然后我将这个库包包含到我的JAdaptiveMPC项目中。 在此处输入图片说明

I get no error in my code syntax, but still, I cannot compile my project. enter image description here

我的代码语法没有错误,但仍然无法编译我的项目。 在此处输入图片说明

Do you know why? I got the same error if I import all those .jarfiles from Maven instead of download the JavaFX SDKand import it into a library.

你知道为什么吗?如果我.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>

Continue

继续

I have added this in the Run Configuration

我已经在 Run Configuration

enter image description here

在此处输入图片说明

And then I try to run enter image description here

然后我试着跑 在此处输入图片说明

Still errors.

还是错误。

采纳答案by Reizo

Your problem is not compiling the project, but running it. Since your mainis defined in your Application-extension, running the project will require JavaFX in your module path on startup.

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

So either outsource your maininto a class different from your Applicationor add the JavaFX modules with VM arguments:

因此,要么将您外包main到与您不同的类中,Application要么添加带有 VM 参数的 JavaFX 模块:

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

See thisfor some more info.

有关更多信息,请参阅此内容

回答by hamza lakhal

The question is old but this how it did work for me in intellij(linux) :

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

1- go to run -> edit configurations

1-去运行->编辑配置

2- add the path in VM Options :

2- 在 VM Options 中添加路径:

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

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