简体   繁体   English

基于NetBeans平台构建的Web Start应用程序不会创建桌面快捷方式和开始菜单项

[英]Web Start Application built on NetBeans Platform doesn't create desktop shortcut & start menu item

I've created a NetBeans Platform application that is launched using Java Web Start. 我创建了一个使用Java Web Start启动的NetBeans平台应用程序。 I built the WAR file using the 'Build JNLP Application'-command in Netbeans 6.8. 我使用Netbeans 6.8中的“Build JNLP Application”命令构建了WAR文件。

I've added a desktop shortcut and menu item to the JNLP file, but for some reason, these are not created when the application is launched. 我已将桌面快捷方式和菜单项添加到JNLP文件中,但由于某些原因,在启动应用程序时不会创建这些快捷方式和菜单项。

However, when I go to: 但是,当我去:

Control Panel -> Java -> Temporary Internet Files -> View -> Select my application > Click 'Install shortcuts to the selected application' 控制面板 - > Java - > Internet临时文件 - >查看 - >选择我的应用程序>单击“安装所选应用程序的快捷方式”

the desktop and menu shortcuts are created correctly. 桌面和菜单快捷方式是正确创建的。

Also, in the Java Console, the Shortcut Creation option is set to the following (the default, I presume): 此外,在Java控制台中,“快捷方式创建”选项设置为以下(默认情况下,我假设):

  • Prompt user if hinted 如果暗示提示用户

Below is a snippet of my JNLP file: 下面是我的JNLP文件的片段:

<jnlp spec="6.0+" codebase="$$codebase">   
      <information>
         <title>${app.title}</title>
         <vendor>SomeVendor (Pty) Ltd</vendor>
         <description>Some description</description>
         <icon href="${app.icon}"/>      
         <shortcut online="true">
            <desktop/>
            <menu submenu="MyApp"/>
         </shortcut>   
      </information>
      ...

I'm stumped. 我很难过。 Does anybody have an explanation for this? 有人对此有解释吗? Thanks 谢谢

PS This is on both Windows XP and Windows 7. NetBeans version: 6.8 PS这适用于Windows XP和Windows 7. NetBeans版本:6.8

I managed to resolve this by using the javax.jnlp.IntegrationService (available since JDK 6.1.18). 我设法通过使用javax.jnlp.IntegrationService(从JDK 6.1.18开始提供)来解决这个问题。

This class can be found in the jnlp.jar found in the JDK samples directory: /sample/jnlp/servlet/jnlp.jar 这个类可以在JDK samples目录中找到的jnlp.jar中找到:/sample/jnlp/servlet/jnlp.jar

The following code ensures that the desktop shortcut and menu shortcut are created: 以下代码可确保创建桌面快捷方式和菜单快捷方式:

private void createShortcuts() {
        IntegrationService vIntegrationService = null;
        try {
            vIntegrationService = (IntegrationService) ServiceManager.lookup("javax.jnlp.IntegrationService");

            if (!vIntegrationService.hasDesktopShortcut() || !vIntegrationService.hasMenuShortcut()) {
                vIntegrationService.requestShortcut(true, true, "App Menu Name");
            }
        } catch(UnavailableServiceException ex){
            ex.printStackTrace();
        }
    }

I have the same problem using Eclipse to build a WebStart application. 我使用Eclipse构建WebStart应用程序时遇到了同样的问题。 I figured it was a limitation of WebStart on Windows. 我认为这是Windows上WebStart的限制。 I figured you can set those properties, but the user still needs to "install" the app to use them. 我想你可以设置这些属性,但用户仍然需要“安装”应用程序才能使用它们。

It's a bit easier to install on the Mac. 在Mac上安装起来要容易一些。 You just right click on the icon in your dock, click on Options and then Keep in Dock. 您只需右键单击Dock中的图标,单击选项,然后单击保留在Dock中。

I have the same issue with Linux, but it works as expected on OS-X. 我对Linux有同样的问题,但它在OS-X上按预期工作。 I have tested with both the Tomcat and the Jetty web container. 我已经使用Tomcat和Jetty Web容器进行了测试。

So, it's a fair chance that your code is actually correct. 因此,您的代码实际上是正确的。

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

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