Java integrates nicely with the user’s desktop OS through JNLP.
Not only does my software show up as a desktop icon, but it is listed as an installed program in the control panel (Windows 7). I was also able to get the JNLP file to auto-configure file association. Now if the user double-clicks a file saved by my program (a pxml file), the program launches. JNLP makes this excellent desktop integration happen smoothly through the web launch.
One issue remains: How do I get my program to load the data file that the user double-clicks? The pxml file is given the same icon as my program, and JNLP created the file association, so windows knows to launch my software when the user tries to open the pxml file. But how does my program know to OPEN that file when it starts?
Below is part of the JNLP file for reference, taken from Proctinator.com
<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"/>
To open an associated file with a Java Web Start launch, use the second element of the parameter array passed to
main(String[] args). The first element will be “-open” when you launch the application by double-clicking a file and args[1] stores the file path of the file we want to open on startup. This feature really makes the Java app feel like a native desktop application.I couldn’t find this in the JNLP documentation.
Here is a sample main method that implements this feature. FileFunction is a class with static methods for application file I/O.