JavaFX运行时组件丢失(Eclipse)

huangapple go评论81阅读模式
英文:

JavaFX runtime components are missing (Eclipse)

问题

在Eclipse中运行JavaFX项目时,我遇到了以下错误:

错误:缺少JavaFX运行时组件,这些组件是运行此应用程序所需的。

我尝试过将以下内容添加到JVM参数中:

--module-path jars/javafx/lib
--add-modules javafx.control, javafx.fxml

但是这会导致以下错误:

错误发生在引导层初始化期间
java.lang.module.FindException:未找到模块javafx.control

JavaFX库的类位于Eclipse的构建路径中,并且在我的“引用库”中明确显示出来。没有编译时错误,只有运行时错误。

需要注意的是,.jar文件本身(javafx.control.jar等)位于“jars/javafx/lib”中,所以我不确定为什么找不到这些模块。

有人知道出了什么问题吗?我看到过一些关于其他IDE的类似问题,但没有解决我的问题。

我的Java运行时版本是:

openjdk版本“11.0.7”2020-04-14
OpenJDK运行时环境(版本11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64位服务器虚拟机(版本11.0.7+10-post-Ubuntu-3ubuntu1,混合模式,共享)

英文:

When running a JavaFX project in Eclipse, I get the following error:

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

I've tried adding
"--module-path jars/javafx/lib
--add-modules javafx.control, javafx.fxml"
to the jvm arguments, but this then gives the error:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.control not found

The javafx library classes are in the eclipse build path and clearly show up in my "Referenced Libraries". There are no compile time errors, just the runtime error.

Note that the .jar files themselves (javafx.control.jar, et cetera) are in "jars/javafx/lib", so I'm not sure why the modules can't be found.

Does anyone know what's going on? I've seen similar questions with other IDEs, but nothing that has worked.

My java runtime is

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

答案1

得分: 2

发现了错误:我应该使用"jars/javafx/lib/"而不是"jars/javafx/lib"。现在它正在运行,最后的"/"有所不同。感谢所有在评论中提供帮助的人。

英文:

Found the error: I should have been using "jars/javafx/lib/" instead of "jars/javafx/lib". It's running now, the last "/" makes the difference. Thanks to all those who offered help in the comments.

huangapple
  • 本文由 发表于 2020年9月25日 12:51:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/64057992.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定