错误:缺少 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
Error: JavaFX runtime components are missing - JavaFX 11 and OpenJDK 11 and Eclipse IDE
提问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.
我也有JavaFX 11 SDK
。顺便一提!如果您想知道,我正在使用 Lubuntu Linux 18.10。
Then I have included the .jar
files from the JavaFX 11 SDK
in Eclipse IDE into a library package.
然后我.jar
将JavaFX 11 SDK
Eclipse IDE 中的文件包含到一个库包中。
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.
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.
你知道为什么吗?如果我.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
Still errors.
还是错误。
采纳答案by Reizo
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
-extension 中定义的,因此在启动时运行该项目将需要在您的模块路径中使用 JavaFX。
So either outsource your main
into a class different from your Application
or 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