Java 中使用 jnlp.jar 的文件关联,没有完整的 JWS? [英] File associations in Java using jnlp.jar, without full JWS?

查看:21
本文介绍了Java 中使用 jnlp.jar 的文件关联,没有完整的 JWS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java Web Start 技术有一个 IntegrationService API 用于创建文件关联.我的问题是是否有可能以某种方式使用这个 API(可能通过在我的应用程序中包含 jnlp.jar)来创建文件关联,但没有完整的 Java Web Start 技术(初始安装没有网站,程序分发传统安装程序或作为简单的可执行 jar 文件).相关应用是桌面/Swing 应用.

The Java Web Start technology has an IntegrationService API for creating file associations. My question is whether it is possible to somehow use this API (possibly by including jnlp.jar in my app) to create file associations, but without the full Java Web Start technology (no website for the initial installation, the program is distributed with a traditional installer or as a simple executable jar file). The app in question is a desktop/swing app.

(这个问题出现在问题的评论中java中如何将文件与程序关联)

(This question arose in the comments of the question How to associate a file with a program in java)

推荐答案

不需要网站在本地使用 jnlp 文件,只需使用 文件 URI 方案,用于 jnlp 代码库jar href.

No web site is required to use a jnlp file locally, just use a file URI scheme for the jnlp codebase and jar href.

这将让您试验文件关联,但您需要先进行备份并清理 Java 首选项缓存.

This will let you experiment with file associations, but you'll want to do a backup and clean the Java Preferences cache first.

附录:

  • 作为一个具体的例子,这个 jnlp 启动了 JFreeChart:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" 
        codebase="file:///Users/trashgod/jnlp/"
        href="jfreechart-1.0.14-demo.jnlp">
    <information>
        <title>JFreeChart 1.0.14 Demo</title>
        <vendor>Object Refinery Ltd</vendor>
        <homepage href="http://www.object-refinery.com/" />
        <description>A demo for the JFreeChart class library</description>
        <description kind="short">JFreeChart demo application.</description>
        <description kind="tooltip">JFreeChart 1.0.14 Demo</description>
        <offline-allowed />
    </information>
    <resources>
        <j2se version="1.5+" initial-heap-size="12m" max-heap-size="256m" />
        <jar href="file:///opt/jfreechart/jfreechart-1.0.14-demo.jar" />
        <jar href="file:///opt/jfreechart/lib/jcommon-1.0.17.jar" />
        <jar href="file:///opt/jfreechart/lib/jfreechart-1.0.14.jar" />
    </resources>
    <application-desc main-class="demo.SuperDemo" />
</jnlp>

  • <association/> 标签使用属性 mime-typeextensions 作为对它希望成为的 JNLP 客户端的提示在操作系统中注册为某些扩展和某些 MIME 类型的主要处理程序."

  • The <association/> tag uses the attributes mime-type and extensions as "a hint to the JNLP client that it wishes to be registered with the operating system as the primary handler of certain extensions and a certain mime-type."

    这篇关于Java 中使用 jnlp.jar 的文件关联,没有完整的 JWS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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