Sam Barnum Sam Barnum - 2 years ago 60
Java Question

JNLP File Association: How do I open the file which was double-clicked on?

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" "">
<jnlp spec="6.0.10" version="1.63" codebase="" href="Foo.jnlp">
<vendor> Foo Systems, Inc.</vendor>
<homepage href=""/>
<description>Foo Viewer/Editor Application</description>
<icon href="splash.gif" width="425" height="102" kind="splash"/>
<icon href="Foo.gif" width="64" height="64"/>
<menu submenu="Foo Systems, Inc."/>
<association mime-type="application-x/wlog" extensions="wlog"/>
<association mime-type="application-x/mplot" extensions="mplot"/>
<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="" value="false"/>
<property name="" value="Foo"/>
<property name="java.util.logging.config.file" value="/Users/Shared/"/>
<application-desc main-class="com.prosc.msi.editor.ui.test.Sandbox"/>

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

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

Any pointers on getting this working?

Answer Source

In a bundled application on Mac OS X, you can implement, 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: is deprecated; instead consider, which provides getApplication().setOpenFileHandler().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download