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. Vue3 和 Vue2 的区别 ?

    1. Vue3 和 VUe2 性能提升 :使用 proxy 代替 defainProperty 实现响应式数据 :使用 ts 书写代码 : 新特性有:组合 api compositionApi  :新 ...

  2. 《刚刚问世》系列初窥篇-Java+Playwright自动化测试-2-环境准备与搭建-基于Maven(详细教程)

    1.简介 上一篇宏哥已经讲解和分享了如何通过引入jar包来搭建Java+Playwright自动化测试环境,这一种是比较老的方法,说白了就是过时的老古董,但是我们必须了解和知道,其实maven搭建无非 ...

  3. List<Map<String,Object>> 属性获取

    public static void main(String[] args) { // 1.数据准备 List<Map<String,Object>> list = new A ...

  4. 《使用Gin框架构建分布式应用》阅读笔记:p251-p271

    <用Gin框架构建分布式应用>学习第14天,p251-p271总结,总21页. 一.技术总结 1.Docker & Docker Compose version: "3. ...

  5. Windows平台安装MongoDB步骤以及问题处理

    今天开始向MongoDB进军,结果一开始就给我来了个下马威--安装不成功,死在了第一步,我滴个乖乖,哪能服气,为了不让后面的小伙伴踩坑,特此记录,希望能帮到有需要的小伙伴. 一.安装步骤 1.下载安装 ...

  6. php 对二维数组按照汉字首字母排序

    1 /** 2 * 取汉字的第一个字的首字母 3 * @param type $str 4 * @return string|null 5 */ 6 function _getFirstCharter ...

  7. BAT之shutdown命令

    今天想让电脑开机后固定时间后重启,但之前只用过关机的命令,就去查询资料,并将shutdown的命令用法整体记录一下. 1 ::取消关机 2 shutdown -a 3 4 ::关机 5 shutdow ...

  8. 19.使用kubeadm-ha脚本一键安装K8S

    使用kubeadm-ha脚本一键安装K8S 前情提示 以前安装k8s集群的时候使用的是k8s官网的教程 使用的镜像源都是国外的 速度慢就不说了 还有一些根本就下载不动 导致安装失败 ,使用一个开源的一 ...

  9. .NET 9使用Scalar替代Swagger

    背景 .NET 9刚刚正式发布了,如果你创建一个空的Asp.Net Core 9.0的Web API项目,启动之后,你会惊讶地发现陪伴你多年的Swagger没有了!--这是因为ASP.NET Core ...

  10. WebUI自动化框架-playwright

    (持续更新) 一.环境准备 安装playwright:playwright是基于python3.7开发的第三方包,所以需要使用的python版本是3.7及其以上的 pip install playwr ...