JNLP文件关联:如何打开双击的文件?

发布于 2024-09-02 01:21:32 字数 2370 浏览 8 评论 0原文

我得到了以下 JNLP:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Descriptor 6.0.10//EN" "http://java.sun.com/dtd/JNLP-6.0.10.dtd">
<jnlp spec="6.0.10" version="1.63" codebase="http://foo.example.com/msi" href="Foo.jnlp">
    <information>
        <title>Foo</title>
        <vendor> Foo Systems, Inc.</vendor>
        <homepage href="http://Foo.com"/>
        <description>Foo Viewer/Editor Application</description>
        <icon href="splash.gif" width="425" height="102" kind="splash"/>
        <icon href="Foo.gif" width="64" height="64"/>
        <offline-allowed/>
        <shortcut>
            <desktop/>
            <menu submenu="Foo Systems, Inc."/>
        </shortcut>
        <association mime-type="application-x/wlog" extensions="wlog"/>
        <association mime-type="application-x/mplot" extensions="mplot"/>
    </information>
    <security>
        <all-permissions/>
    </security>
    <resources>
        <j2se version="1.6+" initial-heap-size="32m" max-heap-size="255m"/>
        <jar href="jars_deployment/TimingFramework-1.0.jar"/>
        <jar href="jars_deployment/iText-2.1.5.jar"/>
        <jar href="jars_deployment/jai_codec.jar"/>
        <jar href="Foo.jar"/>
        <jar href="jars_deployment/TimingFramework-1.0.jar"/>
        <jar href="jars_deployment/iText-2.1.5.jar"/>
        <jar href="jars_deployment/jai_codec.jar"/>
        <jar href="jars_deployment/jsch-20090402.jar"/>
        <property name="apple.laf.useScreenMenuBar" value="true"/>
        <property name="apple.awt.graphics.UseQuartz" value="false"/>
        <property name="com.apple.mrj.application.apple.menu.about.name" value="Foo"/>
        <property name="java.util.logging.config.file" value="/Users/Shared/logging.properties"/>
    </resources>
    <application-desc main-class="com.prosc.msi.editor.ui.test.Sandbox"/>
</jnlp>

几乎一切正常。当我双击 .wlog 文件时,它会打开我的应用程序。但是,它没有打开正确的文件。我在某处读到,JNLP 应该将参数传递给 main 方法,指示哪个文件导致应用程序启动,但这并没有发生(在 OS X 10.6 上)。我的应用程序的 main 方法得到一个空数组。

可能不相关,我的启动屏幕无法工作:(

有关使其工作的任何指示吗?

I've got the following JNLP:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Descriptor 6.0.10//EN" "http://java.sun.com/dtd/JNLP-6.0.10.dtd">
<jnlp spec="6.0.10" version="1.63" codebase="http://foo.example.com/msi" href="Foo.jnlp">
    <information>
        <title>Foo</title>
        <vendor> Foo Systems, Inc.</vendor>
        <homepage href="http://Foo.com"/>
        <description>Foo Viewer/Editor Application</description>
        <icon href="splash.gif" width="425" height="102" kind="splash"/>
        <icon href="Foo.gif" width="64" height="64"/>
        <offline-allowed/>
        <shortcut>
            <desktop/>
            <menu submenu="Foo Systems, Inc."/>
        </shortcut>
        <association mime-type="application-x/wlog" extensions="wlog"/>
        <association mime-type="application-x/mplot" extensions="mplot"/>
    </information>
    <security>
        <all-permissions/>
    </security>
    <resources>
        <j2se version="1.6+" initial-heap-size="32m" max-heap-size="255m"/>
        <jar href="jars_deployment/TimingFramework-1.0.jar"/>
        <jar href="jars_deployment/iText-2.1.5.jar"/>
        <jar href="jars_deployment/jai_codec.jar"/>
        <jar href="Foo.jar"/>
        <jar href="jars_deployment/TimingFramework-1.0.jar"/>
        <jar href="jars_deployment/iText-2.1.5.jar"/>
        <jar href="jars_deployment/jai_codec.jar"/>
        <jar href="jars_deployment/jsch-20090402.jar"/>
        <property name="apple.laf.useScreenMenuBar" value="true"/>
        <property name="apple.awt.graphics.UseQuartz" value="false"/>
        <property name="com.apple.mrj.application.apple.menu.about.name" value="Foo"/>
        <property name="java.util.logging.config.file" value="/Users/Shared/logging.properties"/>
    </resources>
    <application-desc main-class="com.prosc.msi.editor.ui.test.Sandbox"/>
</jnlp>

Most everything is working. When I double-click a .wlog file, it opens up my application. However, it doesn't open the correct file. I read somewhere that JNLP was supposed to pass parameters to the main method indicating which file caused the app to be launched, but this is not happening (on OS X 10.6). I get an empty array to my application's main method.

Probably unrelated, my splash screen doesn't work :(

Any pointers on getting this working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽清梦 2024-09-09 01:21:32

在 Mac OS X 上的捆绑应用程序中,您可以实现 com.apple.eawt.ApplicationListener,如 Mac OS X 参考库示例中所示,< a href="http://developer.apple.com/mac/library/samplecode/OSXAdapter/Introduction/Intro.html" rel="nofollow noreferrer">OSXAdapter:

该示例还通过实现 handleOpenFile() 方法并在其 Info.plist 文件中注册支持的文件类型来支持从 Finder 处理文档。

附录: com.apple.eawt.ApplicationListener 已弃用;而是考虑 com.apple.eawt.Application,它提供了getApplication().setOpenFileHandler()

In a bundled application on Mac OS X, you can implement com.apple.eawt.ApplicationListener, as shown in the Mac OS X Reference Library example, OSXAdapter:

The sample also supports document handing from the Finder by implementing the handleOpenFile() method and registering for supported file types in its Info.plist file.

Addendum: com.apple.eawt.ApplicationListener is deprecated; instead consider com.apple.eawt.Application, which provides getApplication().setOpenFileHandler().

浮萍、无处依 2024-09-09 01:21:32

关于启动窗口

我认为该应用程序只是缺少通往图像的正确路径。
在这种情况下,就像您提到的代码库一样:


< br> 就像你在图中所说的那样:

那么,您的图像必须位于 http 中://foo.example.com/msi/splash.gif

您可能需要确保图像位于该位置......我认为可能是原因。


关于文件关联。

我现在正在同样的情况下工作,并且在从 JNLP API SingleInstanceService 添加服务时似乎正在工作。该服务用于像单例实例一样注册应用程序。因此,每当您的应用程序启动时,它都可以检索用于调用您的应用程序的参数。在这种情况下,您可以使用它来查看双击的文件的名称。
http://download.oracle.com /javase/6/docs/technotes/guides/javaws/developersguide/examples.html#SingleInstanceService
在上面的页面中,您可以找到有关该服务的示例和简要说明。

我发现的问题是,第一次运行应用程序时我看不到文件名。
我的意思是,该服务应该第一次注册应用程序,之后,您将看到用于启动应用程序的参数。因此,使用此服务,如果您第一次通过双击关联文件打开应用程序,您将错过这些参数,直到下一次双击它。您的应用程序现在不会再次打开另一个实例,只是将参数传递给实例化的应用程序。

所以,我找到了另一个解决方案。

http://www.knowledgesutra.com/discuss/tpclso -实现单实例应用程序java.om

上面页面中的男孩使用 Java 安装内部的 jar 文件来查看正在运行的 VM 实例,该实例被调用以查看应用程序启动的参数。它在同一页面中包含用于执行此操作的代码和 jar。

现在我可以看到调用应用程序的行,如下所示:

com.sun.javaws.Main -open C:\\JNLP example\\applet-cartoon\\drawingPack\\drawing_monitor\\ejemplo.ply C:\Users\IsraelAltamira\AppData\Local\Temp\javaws23

其中 ejemplo.ply 是我在 jnlp 描述符中使用的文件扩展名。

好吧,我现在在 OS X 10.6.4 中工作,它似乎可以工作,但此时 Web 启动并没有为我进行文件关联,也没有为已安装的应用程序创建快捷方式...但也许这最后一个解决方案适用于两个系统(至少它可以通过我的假超链接工作,就像上面打开文件的行一样)。

About the splash window

I think the app is just missing the right path to your images.
In this case, like you mention the codebase:

<jnlp spec="6.0.10" version="1.63" codebase="http://foo.example.com/msi" href="Foo.jnlp">

and like you said in the image:
<icon href="splash.gif" width="425" height="102" kind="splash"/>

then, your images have to be in http://foo.example.com/msi/splash.gif

You might want be sure images are in that place.... is what I'm thinking could be the cause.


About the file association.

I'm working right now in the same, and it was seeming to be working while adding a Service from the JNLP API SingleInstanceService. This service is used to register the application like a singleton instance. So, any time your application is lauched, it could retreive the parameters which were used to call you app. In this case, you can use it to see the name of the file that was double clicked on.
http://download.oracle.com/javase/6/docs/technotes/guides/javaws/developersguide/examples.html#SingleInstanceService
In page above you can find an example and a breaf explanation about that service.

The problem that I found with that, is that I could not see the file name the first time that you run the app.
I mean, this service should register the app the first time, and after this time, you will be seeing the parameters used to launch the app. So, with this service if you opened the first time your app through a double click on your associated file, you will miss the parameters, until the next double click on it. Your app now will not open another instance again, just will pass the parameters to the instantiated application.

So, I found another solution for this.

http://www.knowledgesutra.com/discuss/tpclso-implement-single-instance-application-java.om

The boy in the page above, used a jar file from inside the Java installation to see the VM instance running that was invoked to see the parameters of the launch of your app. It has the code and the jar used to do that in this same page.

Now I'm able to see the line that was calling the app, like this:

com.sun.javaws.Main -open C:\\JNLP example\\applet-cartoon\\drawingPack\\drawing_monitor\\ejemplo.ply C:\Users\IsraelAltamira\AppData\Local\Temp\javaws23

where ejemplo.ply is the file extension that I used in the jnlp descriptor.

And well, Im working in OS X 10.6.4 now, and it seems to work, but at this moment the web start is not doing me the file association, and is not doing the shortcuts to the installed app... but maybe this last solution works for both systems (at least it work from my fake hyperlink, like the line above to open the file).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文