打包和部署
# 打包指令
jpackage \
--name "Sign" \
--app-version "1.0" \
--icon "spa_flower.ico" \
--description "signature application" \
--vendor "ronnaces, Inc" \
--copyright "Copyright 2022, All rights reserved" \
--type msi \
--input . \
--dest . \
--main-jar .\ronnaces-signature.jar \
--main-class com.ronnaces.signature.SignatureApplication \
--module-path "D:\Program Files\Java\javafx-sdk-18.0.1\lib" \ # 模块化项目需要
--add-modules javafx.controls,javafx.fxml \ # 模块化项目需要
--jlink-options \
--bind-services \
--verbose \
--win-shortcut \
--win-shortcut-prompt \
--win-menu \
--win-menu-group "ronnaces" \
--win-help-url "https://www.baidu.com" \
--win-dir-chooser \
--win-update-url \
--win-upgrade-uuid "20220622071600"
--type app-image # 用于测试安装包是否可用
--win-console # 用于控制台调试
# 打包步骤
下载 WiX Toolset build tools, 并配置环境变量;
Build Artifacts
Project Settings -> Libraries 删除 javafx lib
Project Settings -> Libraries 添加本地 javafx lib
Build -> Build Project
Edit Configurations -> Add VM options
--module-path "D:\Program Files\Java\javafx-sdk-18.0.1\lib" --add-modules=javafx.controls,javafx.fxml
Project Settings -> Artifacts -> JAR -> From modules with dependencies
Output Layout -> file -> javafx bin
Build Artifacts
删除构建好的jar包里META-INF目录下的 .DSA, .FSA, .SF (通过winRAR里面删除), 并用 java -jar xxx.jar 测试.
执行打包命令
jpackage --name "signature" --app-version "1.0" --icon "spa_flower.ico" --description "signature application 2022-06-26" --vendor "ronnaces, Inc" --copyright "Copyright 2022, All rights reserved" --type msi --input . --dest . --main-jar .\ronnaces-signature.jar --main-class com.ronnaces.signature.App --jlink-options --bind-services --win-shortcut --win-shortcut-prompt --win-menu --win-menu-group "ronnaces" --win-help-url "https://www.baidu.com" --win-dir-chooser --win-update-url "https://www.baidu.com" --win-upgrade-uuid "34b2e00e-e8df-473d-ab70-72ecf876695b" --verbose --win-console
# JLink
# 精简jre镜像
jlink --output jdk-17+fx --module-path "D:\Program Files\Java\javafx-jmods-18.0.1" --add-modules javafx.base,javafx.controls,javafx.fxml,java.base
上次更新: 2024/04/09, 14:15:39