在自包含的 JavaFX 应用程序 (.exe) 中包含一个图标 [英] including an icon into a self-contained JavaFX application (.exe)

查看:27
本文介绍了在自包含的 JavaFX 应用程序 (.exe) 中包含一个图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照此处此处.我正在使用 JDK 7u9NetBeans 7.2.1.我所做的是创建相对于我的项目根文件夹(C:UsersAdministratorDesktopicotestpackagewindowsicotest.ico)的整个路径.我尝试了 48x48 和 256x256 两种尺寸.这是我的项目的树状概览,名为icotest:

│ build.xml│ 清单.mf│├───建造│ │ 内置jar.properties│ ││ ├───类│ │ └───icotest│ │ Main$1.class│ │ 主类│ ││ ├───空│ └───生成源│ └───ap-source-output├───区│ │ icotest.html│ │ icotest.jar│ │ icotest.jnlp│ ││ └───网络文件│ dtjava.js│ 错误.png│ get_java.png│ get_javafx.png│ javafx-chrome.png│ javafx-loading-100x100.gif│ javafx-loading-25x25.gif│ upgrade_java.png│ upgrade_javafx.png│├───nbproject│ │ build-impl.xml│ │ genfiles.properties│ │ jfx-impl.xml│ │ 项目.properties│ │ 项目.xml│ ││ ├───配置│ │ Run_as_WebStart.properties│ │ Run_in_Browser.properties│ ││ └───私人的│ │ 私有.properties│ │ 私有.xml│ ││ └───配置│ Run_as_WebStart.properties│ Run_in_Browser.properties│├───包│ └───窗户│ icotest.ico│└────src└────icotest主程序

这是 build.xml 的样子:

<块引用>

<fx:deploy verbose="true" nativeBundles="exe" outdir="${basedir}/${dist.dir}" outfile="${application.title}"><fx:application name="${application.title}" mainClass="${javafx.main.class}"/><fx:资源><fx:fileset dir="${basedir}/${dist.dir}" includes="*.jar"/><fx:fileset dir="${basedir}/${dist.dir}" includes="lib/*.jar"/></fx:resources><fx:info title="${application.title}" vendor="${application.vendor}"/><fx:preferencesshortcut="true"/></fx:deploy></目标>

无论我做什么 - 在 dist 构建 过程(激活 ISS)期间我仍然收到此消息并设置了 debug 标志true 在相应的 build.xml 文件中:使用默认包资源 [应用程序图标](将 package/windows/icotest.ico 添加到类路径以进行自定义)"

知道我做错了什么吗?谢谢.

解决方案

找到了答案 此处.Oracle 网站上发布的指南目前似乎与可用的实际部署方案不匹配.即,在处理 NetBeans 时,ant 不知道假定为您的根项目的当前目录.正如在相应的论坛主题中所建议的那样 - 只需将包含 "package/windows/${projectname}.ico" 的目录添加到 ant 的类路径,它就会选择相关资源,即使教程声称这应该自动发生,因为现有 (?) 添加了 '.' 到构建脚本.

Followed the instructions here and here. I am using JDK 7u9 and NetBeans 7.2.1. What I did was create the whole path relative to my project's root folder (C:UsersAdministratorDesktopicotestpackagewindowsicotest.ico). I tried both with a 48x48 and a 256x256 size. Here's a tree overview for my project called icotest:

│   build.xml
│   manifest.mf
│
├───build
│   │   built-jar.properties
│   │
│   ├───classes
│   │   └───icotest
│   │           Main$1.class
│   │           Main.class
│   │
│   ├───empty
│   └───generated-sources
│       └───ap-source-output
├───dist
│   │   icotest.html
│   │   icotest.jar
│   │   icotest.jnlp
│   │
│   └───web-files
│           dtjava.js
│           error.png
│           get_java.png
│           get_javafx.png
│           javafx-chrome.png
│           javafx-loading-100x100.gif
│           javafx-loading-25x25.gif
│           upgrade_java.png
│           upgrade_javafx.png
│
├───nbproject
│   │   build-impl.xml
│   │   genfiles.properties
│   │   jfx-impl.xml
│   │   project.properties
│   │   project.xml
│   │
│   ├───configs
│   │       Run_as_WebStart.properties
│   │       Run_in_Browser.properties
│   │
│   └───private
│       │   private.properties
│       │   private.xml
│       │
│       └───configs
│               Run_as_WebStart.properties
│               Run_in_Browser.properties
│
├───package
│   └───windows
│           icotest.ico
│
└───src
    └───icotest
            Main.java

This is what build.xml looks like:

<target name="-post-jfx-deploy">
    <fx:deploy verbose="true" nativeBundles="exe" outdir="${basedir}/${dist.dir}" outfile="${application.title}">
        <fx:application name="${application.title}" mainClass="${javafx.main.class}"/>
        <fx:resources>
            <fx:fileset dir="${basedir}/${dist.dir}" includes="*.jar"/>
            <fx:fileset dir="${basedir}/${dist.dir}" includes="lib/*.jar"/>
        </fx:resources>
        <fx:info title="${application.title}" vendor="${application.vendor}"/>
        <fx:preferences shortcut="true"/>
    </fx:deploy>
</target>

No matter what I do - I still get this message during the dist build process (that activates ISS) with the debug flag set to true in the according build.xml file: "Using default package resource [application icon] (add package/windows/icotest.ico to the class path to customize)"

Any idea what I might be doing wrong? Thank you.

解决方案

Found the answer here. It appears that the guidelines posted on the Oracle's website are currently mismatching the actual deployment scenarios available. Namely, when dealing with NetBeans, ant is unaware of the current directory that is presumed to be your root project. As it has been suggested in the according forum thread - simply add the directory containing "package/windows/${projectname}.ico" to ant's classpath and it will pick up the relevant resource, even though the tutorial claims that this should happen automatically due to the existing (?) addition of '.' to the build script.

这篇关于在自包含的 JavaFX 应用程序 (.exe) 中包含一个图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆