PC's JOGL Blog

Learning the Java JOGL OpenGL Bindings

Saturday, July 15, 2006

JOGL Java Webstart (JNPL)

Turning a JOGL application into a Java webstart application was relatively easy and just involves building a JAR file and creating a JNLP (Java Net Launch Protocol) file. After doing this once I bet you'll probably end up always using webstart to distribute you applications. It is just so easy to work with and installing applications on any browser with Java installed is a snap.

However, I did have a problem when trying to start the application from the browser for the first time. Webstart kept giving me an error message “Java Web Start – Unexpected Error - Unable to launch simpleblending”. When I asked for details, I got the following information (not the most helpful message).

An error occurred while launching/running 
the application.

Title: simpleblending
Vendor: Peter Finch
Category: Unexpected Error

Unexpected exception: java.lang.Exception

I tracked it down to the location I was getting the JOGL extension from. I originally used the prescribed location of https://jogl.dev.java.net/webstart/jogl-1-1.jnlp, however, when I changed this to http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp the problem disappeared and the application started. Perhaps this is a library version problem or something. I understand it is possible to have your own copies of the libraries, which is probably a good idea so that you always know what version or JOGL your application running against. I'll work that out later...

Below is the JNPL file I used and here is a link to the webstart application. Just create a JAR file as you normally would. I like to use Ant scripts to automate the building and deployment for this sort of thing, as it is really easy and built into Eclipse. Note that the first time you load this it will go off and download the JOGL jar and native libraries for your platform. This could take a while (it's about 1.5MB's of data), but the great thing is that once it is downloaded, if any of you other applications use the same location they will reuse the already downloaded version and start up a lot quicking. JNPL even handles version changes (it's so cool!)

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://www.homepla.net/webstart/simpleblending" href="simpleblending.jnlp">
<title>Simple Blending</title>
<vendor>Peter Finch</vendor>
<homepage href="http://www.homepla.net/webstart/simpleblending/" />
<description>JOGL Webstart Example 1</description>
<j2se version="1.4+" />
<jar href="jplanet.jar" />
<property name="sun.java2d.noddraw" value="true"/>
<extension name="jogl" href="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp" />
<application-desc main-class="jplanet.JPlanetWindow" />


Post a Comment

<< Home