Java NetBeans原生打包:如何设置.exe程序的启动画面和ico图片?

Java native packaging in NetBeans: How can I set the splash screen and ico image of .exe program?

我在 NetBeans IDE 中开发了 Java SE 应用程序。我能够编译和 运行 具有初始屏幕和图标图像的 .jar。

对于启动画面,我使用了 NetBeans 项目属性:Properties > Application > Splash Screen 并浏览 src 中的图像项目目录

对于程序的图标图像,我使用了这个代码:

private void formWindowOpened(java.awt.event.WindowEvent evt) {                                  
    java.net.URL url = getClass().getResource("openQCM-icon-30x30.png");
    Toolkit kit = Toolkit.getDefaultToolkit();
    Image img = kit.createImage(url);
    this.setIconImage(img);
}   

.jar 文件一切正常。但我想将我的应用程序分发为 原生包装 以使其独立于目标机器上的 Java 运行 时间。我用过 NetBeans 函数

项目属性 > 构建 > 部署 > 在项目菜单中启用本机打包

然后 项目包为 > 仅图像。

.exe程序没有启动画面和ico图像。如何设置.exe程序的启动画面和ico图像?

Launch4J 似乎可以满足您的需求

The wrapper also provides better user experience through an application icon, a native pre-JRE splash screen, and a Java download page in case the appropriate JRE cannot be found.

http://launch4j.sourceforge.net/

在 NetBeans 8.0+ 中,您可以在 build.xml 文件中指定应用程序图标文件。在build.xml文件中的"import file=..."行后添加下面一行,并将图标文件(如下YourApplication.icns)放在与build.xml.

相同的文件夹中
     <property name="deploy.icon.native" value="${basedir}/YourApplication.icns"/>