Netbeans Java (JavaFX) 带有附加文件和文件夹的本机打包 [英] Netbeans Java (JavaFX) Native Packaging with additional files and folders
问题描述
本地打包 Java 应用程序时如何包含其他文件和文件夹(配置文件)?
How to include additional files and folders (configuration files) when natively packaging Java applications?
在构建项目时,我已经将构建文件设置为创建目录并将其他文件复制到 dist 目录中.
When building the project, I have set the build file to create directories and copy additional files to the dist directory.
我的正常构建(没有本地打包)会导致这个目录结构:
My normal builds (without native packaging) would result to this directory structure:
-> dist
-> lib
-> application.jar
-> config folder //additional folder
-> another additional folder //additional folder
现在,我想构建我的本机安装程序(设置),将那些附加文件夹/文件与我的应用程序和运行时一起提取.
Now, I would like to build my native installer (setup) having those addtional folders/files extracted together with my application and runtime.
基本上当我的本地安装程序运行时,它会创建这些文件:
Basically when my native installer is run, it will create these files:
-> app
-> lib
-> application.jar
-> package.cfg
-> runtime
-> jre
-> applcation.exe
-> application.ico
-> unins000.dat
-> unins000.exe
我的安装程序中不包含我的其他文件和文件夹.我想让我的安装程序提取这些附加文件,最好是这样
My additional files and folders are not included in my installer. I would like to have my installer with those additional files extracted, preferably like this
-> app
-> lib
-> config folder //additional folder
-> another additional folder //additional folder
-> application.jar
-> package.cfg
-> runtime
-> jre
-> applcation.exe
-> application.ico
-> unins000.dat
-> unins000.exe
顺便说一下,我使用 Ant Build 工具和 Inno 进行原生打包.
By the way, I am using Ant Build tool and Inno for native packaging.
推荐答案
我只用 Wix
构建过原生包,所以我的回答基于我从那次经历中获得的知识.将目标添加到您的 Ant
构建脚本并创建一个 fx:deploy
任务.将 nativeBundles
属性设置为 exe.您可以通过将 fx:fileset
s 添加到 fx:application/fx:resources
XPATH 来指定其他文件和文件夹.它可能看起来像这样.
I've only ever built native packages with Wix
, so I'm basing my answer on the knowledge I have from that experience. Add a target to your Ant
build script and create an fx:deploy
task. Set the nativeBundles
attribute to exe. You can specify additional files and folders by adding fx:fileset
s to the fx:application/fx:resources
XPATH. It might looking something like this.
<target name="deploy">
<fx:deploy verbose="true" nativeBundles="exe" ...>
<fx:application name="${app.title}" mainClass="${main.class}" version="${version}">
<fx:resources>
<fx:fileset dir="${base.dir}" includes="config/*.*" />
<fx:fileset dir="${base.dir}" includes="data/*.*" />
</fx:resources>
</fx:application>
</fx:deploy>
</target>
您可以在 fx:resources
部分指定更多内容.Oracle 教程中有更详细的信息,特别是 第 6 节.
There is a lot more you can specify in the fx:resources
section. There's more detailed information in the Oracle tutorials, particularly Section 6.
这篇关于Netbeans Java (JavaFX) 带有附加文件和文件夹的本机打包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!