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. CF102411 ICPC 2019-2020 North-Western Russia Regional Contest题解

    A Accurate Movement 签到 M Managing Difficulties 签到 B Bad Treap 已知\(y=\sin(x)\),要求给出数组\(a[n]\),满足\(\fo ...

  2. .Net 使用JWT验证接口

    // jwt 的生成和接口的验证 // 需要使用的包 // 1. System.IdentityModel.Tokens.Jwt 生成 Token的 // 2. Microsoft.AspNetCor ...

  3. 014 Python 的数据类型(数字、字符串、列表、字典)

    #!/usr/bin/env python # -*- coding:utf-8 -*- # Datatime:2022/7/24 20:31 # Filename:014 Python 的数据类型( ...

  4. 自定义log4j2的PatternLayout参数

    1.添加类 package com.yuanian.micro.config; import org.apache.logging.log4j.core.LogEvent; import org.ap ...

  5. 五分钟一百行代码,手写一个vue项目全局通用的toast提示组件

    前言: 我们已经分享过如何快速实现自己需要的全局弹框组件: 在开发 Vue 项目时,特别是H5页面的项目,还有一个组件是我们非常常用的,它相对弹框来说没有那么大,并且不需要手动关闭在需要更简洁的提示用 ...

  6. 游戏引擎数学库 Plane

    0 前言 平面的表达方式有很多,常用的就两种.向量形式的点法式,标量形式的平面方程.两者可以互相转化. \[(\mathbf{p}-\mathbf{p_0})\cdot\mathbf{n}=0 \] ...

  7. ROS入门21讲(2)

    四.创建工作空间与功能包 1.工作空间 工作空间(workspace):是一个存放工程开发相关文件的文件夹(相当于在IDE中创建的工程文件). 包含: src:代码空间(Source Space),放 ...

  8. docker存储配置与管理--项目三

    一.Docker存储概念 1.容器本地存储与Docke存储驱动 容器本地存储:每个容器都被自动分配了内部存储,即容器本地存储.采用的是联合文件系统.通过存 储驱动进行管理. 容器本地存储空间:分层结构 ...

  9. .NET云原生应用实践(五):使用Blazor WebAssembly实现前端页面

    本章目标 使用Blazor WebAssembly实现管理"贴纸"页面 集成认证与授权机制 如果你对Blazor WebAssembly的使用不感兴趣,可以跳过本章的阅读.你也可以 ...

  10. WinDbg符号配置

    符号文件介绍 它包含了应用程序二进制文件(比如:EXE.DLL等)调试信息,专门用来作调试之用,最终生成的可执行文件在运行时并不需要这个符号文件,但你的程序中所有的变量信息都记录在这个文件中.所以调试 ...