简体   繁体   English

使用Java Webstart创建桌面快捷方式

[英]Create desktop shortcut with Java Webstart

I have a Java application (a JAR file) which runs using Java Web Start. 我有一个使用Java Web Start运行的Java应用程序(一个JAR文件)。 All is weel in terms of the application actually running. 就实际运行的应用程序而言,一切都是we花一现。

What does not work is the shortcut being installed by JWS. 不起作用的是JWS正在安装的快捷方式。 Here is my JNLP file <information> tag 这是我的JNLP文件<information>标记

<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. 现在我知道一个主要问题是快捷方式安装被我们的IT策略阻止了。

安装被阻止

The shortcuts do install if i do it directly from the Java Cache Viewer 如果我直接从Java Cache Viewer中进行安装,则快捷方式确实会安装

在此处输入图片说明

I tried doing it from the JAVAWS tool but that did not work either. 我尝试通过JAVAWS工具执行此操作,但这也不起作用。

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: 在使用该JNLP表示法创建快捷方式时,我们还存在一些问题,因此此代码可以做到这一点:

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. 这使用了jnlp.jar提供的JNLP Integration Service。 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. 该jar与JRE捆绑在一起,因此您将需要配置构建过程来定位它,但无需将其提供给客户。

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

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