错误:缺少 JavaFX 运行时组件,需要使用 JDK 11 运行此应用程序 [英] Error: JavaFX runtime components are missing, and are required to run this application with JDK 11

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

问题描述

我正在尝试使用 IntelliJ 运行示例 JavaFX 项目,但它因异常而失败:

I'm trying to run the sample JavaFX project using IntelliJ but it fails with the exception :

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

我在这里下载了 JDK 11:http://jdk.java.net/11/我在这里下载了 OpenJFX:http://jdk.java.net/openjfx/我正在使用:IntelliJ IDEA 2018.2(社区版)Build #IC-182.3684.40,建于 2018 年 7 月 17 日JRE:1.8.0_152-release-1248-b8 amd64JVM:JetBrains s.r.o 的 OpenJDK 64 位服务器 VM视窗 10 10.0

I have downloaded JDK 11 here : http://jdk.java.net/11/ I have downloaded OpenJFX here : http://jdk.java.net/openjfx/ I'm using : IntelliJ IDEA 2018.2 (Community Edition) Build #IC-182.3684.40, built on July 17, 2018 JRE: 1.8.0_152-release-1248-b8 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0

我使用 JDK 11 在 IntelliJ 中创建了一个新的 JavaFX 项目.我的 JavaFX 类未知,因此我通过执行以下操作添加了 OpenJFX 库:

I have created a new JavaFX project in IntelliJ using JDK 11. My JavaFX classes were not known so I have added the OpenJFX library by doing :

  • 文件 -> 项目结构 -> 模块 -> + -> 库 -> Java

我在 OpenJFX 中添加了类"下方的 8 个 jar,以及源"下方的文件夹以及本机库位置"下方的 bin 文件夹路径.

I have the OpenJFX added with the 8 jars below "classes" and also the folders below "Sources" and the path to the bin folder under "Native Library Locations".

当我构建项目时,它很好,但无法运行它.

When I'm building the project, it's good, but impossible to run it.

我做错了什么?

推荐答案

这对我有用:

文件>>项目结构>>模块>>依赖>>+(在窗口左侧)

File >> Project Structure >> Modules >> Dependency >> + (on left-side of window)

点击+"号会让你指定解压JavaFX的lib"文件夹的目录.

clicking the "+" sign will let you designate the directory where you have unpacked JavaFX's "lib" folder.

Scope 是 Compile(这是默认值.)然后,您可以通过双击该行来编辑它以将其称为 JavaFX.

Scope is Compile (which is the default.) You can then edit this to call it JavaFX by double-clicking on the line.

然后在:

运行>>编辑配置

将此行添加到 VM 选项:

Add this line to VM Options:

--module-path /path/to/JavaFX/lib --add-modules=javafx.controls

(哦,别忘了设置SDK)

(oh and don't forget to set the SDK)

这篇关于错误:缺少 JavaFX 运行时组件,需要使用 JDK 11 运行此应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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