且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在IntelliJ IDEA IDE中运行JavaFX应用程序

更新时间:2022-05-20 02:43:01

官方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