繁体   English   中英

Java JNLP桌面快捷方式和图标

[英]Java JNLP Desktop Shortcut and Icon

Java通过JNLP与用户的桌面操作系统很好地集成在一起。 我的软件不仅显示为桌面图标,而且在控制面板(Windows 7)中列为已安装的程序。 我还能够获取JNLP文件来自动配置文件关联。 现在,如果用户双击由我的程序保存的文件(一个pxml文件),该程序将启动。 JNLP通过Web启动使这种出色的桌面集成顺利进行。 仍然存在一个问题:如何使我的程序加载用户双击的数据文件? 给pxml文件提供了与我的程序相同的图标,并且JNLP创建了文件关联,因此当用户尝试打开pxml文件时,windows知道启动我的软件。 但是我的程序如何知道在启动时打开该文件?

以下是摘自Proctinator.com的JNLP文件的一部分,以供参考。

<jnlp  spec="6.0+" codebase="http://proctinator.com/dist" >
  <information>
    <title>The Proctinator</title>
    <vendor>Smart Software Solutions, INC.</vendor>
    <homepage href="http://proctinator.com"/>
    <description kind="short">The Proctinator exam scheduling software</description>
    <icon kind="splash" href="splashScreen.jpg" />
    <icon kind="shortcut" href="bigP.jpg" />
    <offline-allowed/> 
    <association extensions="pxml" mime-type="application/pxml"/>
    <shortcut online="false">
      <desktop/>
    </shortcut>
  </information>
  <resources>    <j2se version="1.6+"/> ...  </resources>
<application-desc main-class="thornworks.proctor.GUI"/>

要通过启动Java Web Start打开关联文件,请使用传递给main(String[] args)的参数数组的第二个元素。 通过双击文件启动应用程序时,第一个元素为“ -open”,而args [1]存储我们要在启动时打开的文件的文件路径。 该功能确实使Java应用程序看起来像本机桌面应用程序。

我在JNLP文档中找不到。

这是实现此功能的示例主要方法。 FileFunction是带有用于应用程序文件I / O的静态方法的类。

public static void main(String[] args) {
    GUI win = new GUI(null);
    if(args.length==2) {
        win = new GUI(null);
        StringBuilder params = new StringBuilder();
        for(String s : args) {
            params.append(s);
            params.append("\n");
        }
        JOptionPane.showMessageDialog(null, params);
        try {
            FileFunction.loadList(new FileInputStream(new File(args[1])));
        }
        catch(IOException ioe) {
            FileFunction.showFileError(ioe);
        }
    }

暂无
暂无

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

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