https://openjfx.io/openjfx-docs/#maven

Run HelloWorld using Maven

If you want to develop JavaFX applications using Maven, you don't have to download the JavaFX SDK. Just specify the modules and the versions you want in the pom.xml, and the build system will download the required modules, including the native libraries for your platform.

Here is a pom.xml file which shows how to achieve this, included in this sample.

Alternatively, we have created JavaFX Maven Archetypes to quickly create Maven projects. A simple JavaFX project can be created by executing the following command:


mvn archetype:generate \
-DarchetypeGroupId=org.openjfx \
-DarchetypeArtifactId=javafx-archetype-simple \
-DarchetypeVersion=0.0.3 \
-DgroupId=org.openjfx \
-DartifactId=sample \
-Dversion=1.0.0 \
-Djavafx-version=17

The pom uses the JavaFX Maven plugin:


<plugins>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>HelloFX</mainClass>
</configuration>
</plugin>
</plugins>

Add the maven dependencies:


<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17</version>
</dependency>
</dependencies>

Important: Note that transitive dependencies are automatically resolved (for instance, there is no need to add a dependency for the javafx.graphics module, since it is transitively resolved by the javafx.controls module). But if your application is using FXML, you will need to add a dependency for the javafx.fxml module as well.

Finally, run the application (e.g. based on the HelloFX.java from the referred sample):


mvn clean javafx:run
Note: Make sure to set the JAVA_HOME environment variable to the correct JDK location.

Getting Started with JavaFX的更多相关文章

  1. 问题记录:JavaFx 鼠标滑轮滚动事件监听!

    问题描述: 在listview的item里面添加鼠标拖拽排序功能.代码如下: setOnMouseDragged(event -> { //设定鼠标长按0.3秒后才可拖拽 防止误操作 isCan ...

  2. JavaFx客户端服务器C/S架构搭建

    客户端获取服务器端软件更新版本方法: package com.platform.ui.update; import java.io.BufferedInputStream; import java.i ...

  3. JavaFX 教程资料收集

    1. JavaFX中文资料 http://www.javafxchina.net/blog/docs/tutorial1/ 2. JavaFX入门教程 http://www.xrpmoon.com/c ...

  4. 在 linux 上部署并运行 JavaFX 项目

    环境 redhat 6.4.eclipse安装JavaFX插件 项目详情及代码参见 在linux上配置并创建JavaFX项目 ,该部署即此文章中项目的部署 配置build.fxbuild 生成buil ...

  5. 在linux上配置并创建JavaFX项目

    本环境为linux配置,因为这里的JavaFX项目是为定制Oracle监控工具而写的.现Oracle已收购Java好几年,用它自己的产生监控自己的东西还是很兼容的.此处Eclipse 为4.5版本. ...

  6. javafx之登陆界面的跳转

    界面布局用到的是fxml而非纯java代码,工具是javafx sence builder 账号:account 密码:password 登陆成功: 可以点击退出登陆返回到登陆页面 工程目录: pac ...

  7. JAVAFX纯手写布局

    主页面效果: 第一栏的效果: 工程目录: package MessageBean; /** * * @author novo */ public class Message { private Str ...

  8. javafx之HTTP协议交互

    javafx端要获取获取如下信息: 服务器端获取的数据: javafx客户端发送的数据以及获取的数据: 工程目录: package Httputil; import IPsite.IPaddress; ...

  9. eclipse开发 javafx(转)

    了解过JavaFX的都知道,JavaFX自从2.0版本开始,已经完全抛弃了之前的script语言,才用纯java来实现.这样的好处就是1.让使用Java的IDE进行JavaFX的开发成为可能,2.Ja ...

  10. JavaFX結合 JDBC, Servlet, Swing, Google Map及動態產生比例圖 (3):部署設定及應用 (转帖)

    說明:這一篇主要是說明如何將程式部署到Application Server,以及程式如何運作,產生的檔案置於何處,以及如何以瀏覽器呈現(Applet),或是當成桌面應用程式,或是 桌面Applet,這 ...

随机推荐

  1. 74.数组map能干什么,会改变原数组吗

    map是处理数据的方法,不会改变原数组,会返回一个新数组 : filter 也不会改变原数组,会返回新数组 : forEach 也不会改变原数组,不会返回新数组 : reduce不会改变原数组 : 是 ...

  2. MYSQL存储过程-练习3 repeat循环

    MYSQL存储过程-练习3 repeat循环 1 DELIMITER $$ 2 3 CREATE PROCEDURE `sp_repeat`() 4 BEGIN 5 DECLARE i INT; 6 ...

  3. 21 如何写出一篇高质量的sci水文

    博客配套视频链接: https://www.bilibili.com/video/BV1fW4y1W7dS/ b 站直接看 模型确定, 结果正在跑(或已结束), 目标期刊已定,一般可以定顶刊 从目标期 ...

  4. EBS GL 当前职责有访问权限的所有账套

    CREATE OR REPLACE VIEW CUX_GL_ACCESS_LEDGER_V AS SELECT L.LEDGER_ID,L.NAME,L.LEDGER_CATEGORY_CODE FR ...

  5. KubeSphere v4 开源并发布全新可插拔架构 LuBan

    2024 年 10 月 10 日,KubeSphere 开源社区激动地向大家宣布,KubeSphere v4(开源版)已正式发布,同时发布全新可插拔架构 KubeSphere LuBan. 相较于 K ...

  6. java的split方法的转义字符

    一.实例 我们都知道  String s="ad,dfjdlfs,df,s,dfl"; 执行 String re[]=s.split(",");     则re ...

  7. vscode+码云(gitee),用git进行源代码管理

    使用原因 对于我们经常换电脑来工作的人群,在公司工作完,回家里再用U盘或网盘复制/下载我们的代码,简直是一种折磨,一个项目中断后,时间久了再去想继续的时候,你会发现:到底哪个是最新版的?!U盘满了,这 ...

  8. js常用函数 _01 关于 model()、substr() 和 正则表达式的使用

    js常用函数 _01 关于 model().substr() 和 正则表达式的使用 1.model() Bootstrap 模态框(Modal)插件 模态框(Modal)是覆盖在父窗体上的子窗体.通常 ...

  9. WPF学习-布局

    1.  Grid布局 ,(Table 布局) 两行两列布局, Border  0 行 0 列默认开始 <Window x:Class="WpfApp.MainWindow" ...

  10. NOIP2024模拟3:一路破冰

    NOIP2024模拟3:一路破冰 雨后的青山.--240316 A-无向图删边 一句话题面:规定一轮中的删边方式为:按边权递减且每轮删掉的边集中没有环.问每条边会在第几轮被删除. 暴力的想法就是跑 \ ...