错误:缺少JavaFX运行时组件-JavaFX 11和OpenJDK 11和Eclipse IDE [英] Error: JavaFX runtime components are missing - JavaFX 11 and OpenJDK 11 and Eclipse IDE

查看:212
本文介绍了错误:缺少JavaFX运行时组件-JavaFX 11和OpenJDK 11和Eclipse IDE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

我有OpenJDK 11.0.2

I have 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.

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

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

Then I have included the .jar files from the JavaFX 11 SDK in Eclipse IDE into a library package.

然后,我已将此库软件包包含在我的JAdaptiveMPC项目中.

Then I have included this library package into my JAdaptiveMPC project.

我的代码语法没有错误,但是仍然无法编译我的项目.

I get no error in my code syntax, but still, I cannot compile my project.

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

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

<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

然后我尝试运行

仍然存在错误.

推荐答案

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

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

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

So either outsource your main into a class different from your Application or add the JavaFX modules with VM arguments:

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

有关更多信息,请参见.

See this for some more info.

这篇关于错误:缺少JavaFX运行时组件-JavaFX 11和OpenJDK 11和Eclipse IDE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆