如何在IntelliJ IDEA IDE中运行JavaFX应用程序 [英] How to run javafx applications in intellij idea IDE

查看:1186
本文介绍了如何在IntelliJ IDEA IDE中运行JavaFX应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行JavaFX应用程序,但显示以下错误

I am trying to run JavaFX application but there is showing the following error

错误:缺少JavaFX运行时组件,并且是运行此应用程序所必需的

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

在这一步之前,我无法导入JavaFX,并且已经从/usr/lib/jvm/java-8-openjdk-amd64完成了

Until this step, I could not import the JavaFX, and I have done it from /usr/lib/jvm/java-8-openjdk-amd64

有人可以帮助解决此错误吗?

Can someone help to solve this error?

预先感谢. 顺便说一下,我正在使用lubuntu操作系统

Thanks beforehand. By the way, I am using lubuntu operating system

其他信息

推荐答案

官方OpenJFX所述网站

  • 打开您的intellij idea IDE并创建新项目
  • 转到文件>项目结构
  • 转到项目设置>库
  • 点击 + 按钮
  • 从解压缩的openJFX 11 zip中找到 .. \ openjfx-11.0.1_windows-x64_bin-sdk \ javafx-sdk-11.0.1 \ lib 文件夹
  • 应用设置,然后点击确定
  • 转到文件>设置
  • 在设置"中,转到"外观和设置".行为>系统设置>路径变量
  • 单击 + 并添加名为 PATH_TO_FX 的新路径变量,然后在值"字段中找到 .. \ openjfx-11.0.1_windows-x64_bin-sdk \ javafx -sdk-11.0.1 \ lib 文件夹
  • 应用设置,然后点击确定
  • 转到运行>编辑配置
  • 应用程序> {您的应用程序名称}
  • 中选择您的应用程序
  • 然后点击配置标签,并在 VM选项字段中输入以下内容: -模块路径$ {PATH_TO_FX} --add-modules = javafx.controls,javafx.fxml
  • 然后单击 编辑模板"按钮在模板"中选择应用程序",然后在 VM选项中现场这样写: -模块路径$ {PATH_TO_FX} --add-modules = javafx.controls,javafx.fxml
  • 应用设置,然后点击确定,现在一切就绪
  • 每当您在intellij中创建新项目时都必须这样做
  • open your intellij idea IDE and create new Project
  • Go to File > Project Structure
  • Go to Project Settings > Libraries
  • Click on + button
  • Locate ..\openjfx-11.0.1_windows-x64_bin-sdk\javafx-sdk-11.0.1\lib folder from extracted zip of openJFX 11
  • Apply settings and click ok
  • Go to File > Settings
  • In Settings go to Appearance & Behavior > System Settings > Path Variables
  • Click on + and add new path variable name it PATH_TO_FX and in value field locate ..\openjfx-11.0.1_windows-x64_bin-sdk\javafx-sdk-11.0.1\lib folder
  • Apply settings and click ok
  • The go to Run > Edit Configurations
  • Select your Application from Application > {your application name}
  • Then click on Configuration tab and in VM options field write this: --module-path ${PATH_TO_FX} --add-modules=javafx.controls,javafx.fxml
  • Then Click on Edit templates button select Application in Templates and again in VM options field write this: --module-path ${PATH_TO_FX} --add-modules=javafx.controls,javafx.fxml
  • Apply settings and click ok and now you are good to go
  • You have to do this whenever you create new project in intellij

这篇关于如何在IntelliJ IDEA IDE中运行JavaFX应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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