构建在 NetBeans 平台上的 Web Start 应用程序不会创建桌面快捷方式 &开始菜单项 [英] Web Start Application built on NetBeans Platform doesn't create desktop shortcut & start menu item

查看:37
本文介绍了构建在 NetBeans 平台上的 Web Start 应用程序不会创建桌面快捷方式 &开始菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个使用 Java Web Start 启动的 NetBeans 平台应用程序.我使用 Netbeans 6.8 中的构建 JNLP 应用程序"命令构建了 WAR 文件.

我已将桌面快捷方式和菜单项添加到 JNLP 文件中,但由于某种原因,这些在应用程序启动时并未创建.

但是,当我去:

<块引用>

控制面板 -> Java -> 临时Internet 文件 -> 查看 -> 选择我的应用程序 > 单击安装快捷方式"到选定的应用程序'

正确创建了桌面和菜单快捷方式.

此外,在 Java 控制台中,快捷方式创建选项设置如下(我认为是默认设置):

  • 提示用户提示

以下是我的 JNLP 文件的片段:

<信息><title>${app.title}</title><vendor>SomeVendor (Pty) Ltd</vendor><description>一些描述</description><icon href="${app.icon}"/><shortcut online="true"><桌面/><menu submenu="MyApp"/></快捷方式></信息>...

我被难住了.有人对此有解释吗?谢谢

PS 这适用于 Windows XP 和 Windows 7.NetBeans 版本:6.8

解决方案

我通过使用 javax.jnlp.IntegrationService(从 JDK 6.1.18 开始可用)设法解决了这个问题.

这个类可以在JDK示例目录下的jnlp.jar中找到:/sample/jnlp/servlet/jnlp.jar

以下代码确保创建桌面快捷方式和菜单快捷方式:

<前>私有无效 createShortcuts() {IntegrationService vIntegrationService = null;尝试 {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've created a NetBeans Platform application that is launched using Java Web Start. I built the WAR file using the 'Build JNLP Application'-command in Netbeans 6.8.

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.

However, when I go to:

Control Panel -> Java -> Temporary Internet Files -> View -> Select my application > Click 'Install shortcuts to the selected application'

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):

  • Prompt user if hinted

Below is a snippet of my JNLP file:

<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

解决方案

I managed to resolve this by using the javax.jnlp.IntegrationService (available since JDK 6.1.18).

This class can be found in the jnlp.jar found in the JDK samples directory: /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();
        }
    }

这篇关于构建在 NetBeans 平台上的 Web Start 应用程序不会创建桌面快捷方式 &amp;开始菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆