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. vant2 自动检查表单验证 -validate

    ref 给 <van-form @submit="onSubmit" ref="form"> 标签 : // 检验手机号是否合格 await thi ...

  2. 时隔半年 DotNetGuide 已突破了 6.6K + Star,持续更新,欢迎更多小伙伴PR投稿!

    前言 记得今年5月份的时候 DotNetGuide GitHub才突破5k Star,经过持续不断地输出时隔半年 DotNetGuide 已突破了 6.6K + Star!并且由我创建的DotNetG ...

  3. sqlplus登录脚本glogin.sql的配置

    DEFINE sqlprompt=SQL COLUMN sqlprompt NEW_VALUE sqlprompt SET TERMOUT OFF SELECT USER || '@' || NVL( ...

  4. vue3+tpyeScript + element plus 三级复选框,全选控制全部,左侧选中控制右侧全选

    .markdown-body { line-height: 1.75; font-weight: 400; font-size: 16px; overflow-x: hidden; color: rg ...

  5. 云原生周刊:KubeSphere 3.4.1 发布 | 2023.11.13

    开源项目推荐 Inspektor Gadget Inspektor Gadget 是一组用于调试和检查 Kubernetes 资源与应用程序的工具(或小工具).它在 Kubernetes 集群中管理 ...

  6. TypeError: add_triangle_mesh(): incompatible function arguments. The following argument types are supported: 问题终于解决了!!!!

    1 2024.10.12 14:52 Traceback (most recent call last): File "terrain_creation.py", line 119 ...

  7. 24暑集训Week1

    24暑集训Week1 夜行的人,若你不唱歌的话,不惊醒这黑夜的话,就永远也走不出呼蓝别斯了. 这重重的森林,这崎岖纤细的山路,这孤独疲惫的心. 亲爱的,哪怕后来去到了城市,走夜路时也要大声地唱歌,像喝 ...

  8. games101_Homework3

    在Raster部分实现数值插值,然后实现四种不同的像素着色器 作业描述: 作业1:修改函数 rasterize_triangle(const Triangle& t) in rasterize ...

  9. 盘点阿里、腾讯、百度大厂C#开源项目

    BAT作为互联网第一梯队的互联网公司,他们开源的项目都是发自内心地将踩过的坑和总结的经验融入到开源项目中,供业界所有人使用,希望帮助他人解决问题. 目前互联网的大厂开源的项目涉及各种语言,项目类型包含 ...

  10. P3523 POI2011 DYN-Dynamite

    P3523 POI2011 DYN-Dynamite 小 trick,加双倍经验. 思路 使 \(dis\) 的最大值最小,可以想到二分 \(dis\),然后根据 \(dis\) 判断可行性. 那么可 ...