codeNinja
codeNinja

Reputation: 1462

Create desktop shortcut with Java Webstart

I have a Java application (a JAR file) which runs using Java Web Start. All is weel in terms of the application actually running.

What does not work is the shortcut being installed by JWS. Here is my JNLP file <information> tag

<information>
    <title>My App</title>
    <vendor>My Company</vendor>
    <homepage href="http://example.com"/>
    <description>My Description</description>
    <description kind="short">desc short</description>
    <icon href="splash.png" kind="splash"/>
    <icon kind="shortcut" href="icon.png" />
    <shortcut online="false" install="true">  
        <desktop/>  
        <menu submenu="My APP"/>  
    </shortcut> 
</information>

Now I know one major problem is that Shortcut install is blocked by our IT policy.

Install Blocked

The shortcuts do install if i do it directly from the Java Cache Viewer

enter image description here

I tried doing it from the JAVAWS tool but that did not work either.

javaws -verbose -import -silent -shortcut my-file.jnlp

What can i do so that i can automatically install shortcuts when my application is deployed?

Upvotes: 1

Views: 5806

Answers (1)

Denis Falqueto
Denis Falqueto

Reputation: 31

We also have some problems in creating shortcuts with that JNLP notation, so this code does it:

public static final String JAVAXJNLP_INTEGRATION_SERVICE = "javax.jnlp.IntegrationService";

public static void criaAtalhosWebStart() {
    IntegrationService integ;
    try {
        integ = (IntegrationService) ServiceManager.lookup(JAVAXJNLP_INTEGRATION_SERVICE);
        if (integ != null) {
            if (!integ.hasDesktopShortcut() || !integ.hasMenuShortcut()) {
                integ.requestShortcut(true, true, "Shorcut Label");
            }
        }
    } catch (UnavailableServiceException ex) {
        System.out.println("Error in creating shorcut: " + ex.getMessage());
    }
}

This uses JNLP Integration Service, which is provided by jnlp.jar. That jar comes bundled with JRE, so you will need to configure your build process to locate it, but you don't need to provide it to your clients.

Upvotes: 1

Related Questions