简体   繁体   中英

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.

安装被阻止

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

在此处输入图片说明

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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