Creating a desktop icon using JWS JNLP for a JavaFX app

前端 未结 5 929
傲寒
傲寒 2021-01-13 00:53

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. I have tried everything I can

相关标签:
5条回答
  • 2021-01-13 01:29

    I suppose the problem in your case is the missing CODEBASE attribute. 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>
    
    0 讨论(0)
  • 2021-01-13 01:37

    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.

    If you haven't done so already, maybe checking the JNLP code for MaiTai would give you some pointers.

    0 讨论(0)
  • 2021-01-13 01:44

    We had the same problem. It worked fine initially then over time (a few Java updates?) it stopped working. When I got around to troubleshooting I discovered that even though javaws sends that it is gzip capable, our gzip response was not handled. I turned gzip off for these icons and it worked fine once again.

    0 讨论(0)
  • 2021-01-13 01:50

    I would try the following, in order:

    1. Create an icon of 32x32 in size and add it as an additional <icon kind="shortcut".... The spec says that size is used for desktop icons.
    2. Use your 64x64 icon as the "default". For example, your new <icon> elements would be:

      <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

    4. If none of those work, you are welcome to compare your JNLP to one of mine that works.

    I realize that this JNLP stuff is kind of a pain. Hope one of these work for you.

    0 讨论(0)
  • 2021-01-13 01:52

    There's an example of how to do this in the JavaFX in Action book, if you have access to that. 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. Try loading it directly in a browser to ensure its available/valid.

    0 讨论(0)
提交回复
热议问题