简体   繁体   English

使用JWS JNLP为JavaFX应用程序创建桌面图标

[英]Creating a desktop icon using JWS JNLP for a JavaFX app

I am trying to get a custom destop icon to be displayed for my app but for some reason no matter what I do the same default java icon shows up. 我正在尝试为我的应用程序显示一个自定义destop图标,但由于某些原因,无论我做什么,都会显示相同的默认java图标。 I have tried everything I can think of and gone and compared my jnlp file with others whose icons seem to work ok. 我已经尝试了所有我能想到的东西,并将我的jnlp文件与其图标似乎正常工作的其他人进行了比较。 According to everything I have read the following should work fine. 根据我读过的所有内容,以下内容应该可以正常工作。 But of course, it doesn't: 但当然,它没有:

<information>
    <title>MikesApp</title>
    <vendor>Mike</vendor>
    <homepage href="http://www.mikesapp.com/"/>
    <description>Mikes App.</description>
    <icon kind="shortcut" href="res/icon64x64.png" width="64" height="64"/>
    <offline-allowed/>
    <shortcut>
        <desktop/>
    </shortcut>
</information>

Any ideas would be greatly appreciated. 任何想法将不胜感激。

I would try the following, in order: 我会按顺序尝试以下方法:

  1. Create an icon of 32x32 in size and add it as an additional <icon kind="shortcut"... . 创建一个32x32大小的图标,并将其添加为另外的<icon kind="shortcut"... The spec says that size is used for desktop icons. 规范说大小用于桌面图标。
  2. Use your 64x64 icon as the "default". 使用64x64图标作为“默认”。 For example, your new <icon> elements would be: 例如,您的新<icon>元素将是:

     <icon href="res/icon64x64.png" width="64" height="64"/> <icon kind="shortcut" href="res/icon32x32.png" width="32" height="32"/> <icon kind="shortcut" href="res/icon64x64.png" width="64" height="64"/> 
  3. Remember that your images are accessed relative to your codebase attribute in your jnlp xml element 请记住,您的图像是相对于jnlp xml元素中的codebase属性访问的

  4. If none of those work, you are welcome to compare your JNLP to one of mine that works . 如果这些都不起作用,欢迎您将您的JNLP与我的 JNLP进行比较。

I realize that this JNLP stuff is kind of a pain. 我意识到这个JNLP的东西是一种痛苦。 Hope one of these work for you. 希望其中一个为你工作。

We had the same problem. 我们遇到了同样的问题。 It worked fine initially then over time (a few Java updates?) it stopped working. 它最初工作得很好然后随着时间的推移(一些Java更新?)它停止工作。 When I got around to troubleshooting I discovered that even though javaws sends that it is gzip capable, our gzip response was not handled. 当我开始排除故障时,我发现即使javaws发送它是gzip能力的,我们的gzip响应也没有得到处理。 I turned gzip off for these icons and it worked fine once again. 我为这些图标关闭了gzip,它再次正常工作。

I suppose the problem in your case is the missing CODEBASE attribute. 我想你的案例中的问题是缺少CODEBASE属性。 See one working snippet: 查看一个工作片段:

<?xml version="1.0"?>
<jnlp spec="1.5+" 
      codebase="http://www.sweethome3d.com/" 
      href="SweetHome3D.jnlp">
  <information>
    <title>Sweet Home 3D</title>
    <vendor>eTeks</vendor>
    <homepage href="http://www.sweethome3d.com/"/>
    <description>Sweet Home 3D</description>
    <description kind="short">Arrange the furniture of your house</description>
    <icon href="SweetHome3DIcon.gif"/>
    <icon kind="splash" href="SweetHome3DSplashScreen.jpg"/>
    <offline-allowed/>
    <shortcut online="false">
      <desktop/>
      <menu submenu="eTeks Sweet Home 3D"/>
    </shortcut>
    <association extensions="sh3d sh3l sh3f sh3t sh3p" 
                 mime-type="application/SweetHome3D"/>
  </information>

I don't have a specific answer I'm afraid, but Project MaiTai is an open source application written in JavaFX, and that has a custom desktop icon. 我恐怕没有具体的答案,但Project MaiTai是一个用JavaFX编写的开源应用程序,它有一个自定义桌面图标。

If you haven't done so already, maybe checking the JNLP code for MaiTai would give you some pointers. 如果你还没有这样做,也许检查MaiTai的JNLP代码会给你一些指示。

There's an example of how to do this in the JavaFX in Action book, if you have access to that. 如果您有权访问JavaFX in Action手册中有一个如何执行此操作的示例。 You need to make sure the res/icon64x64.png file is actually downloadable from whatever site the app is hosted on, relative to the JNLP's location. 您需要确保res / icon64x64.png文件实际上可以从托管应用程序的任何站点下载,相对于JNLP的位置。 Try loading it directly in a browser to ensure its available/valid. 尝试直接在浏览器中加载它以确保其可用/有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM