Monday, May 15, 2006

Java Web Start shortens my time on earth

First, for posterity, you can make a JNLP file into a JSP file (for dynamic control) by simply calling your file something.jsp instead of something.jnlp and using the line

<%@ page contentType="application/x-java-jnlp-file"%>

at the very top.

Now, on to the main article.

The problem: I want to use JOGL (some Java API for OpenGL) to make a web start application. This will need some jars to be signed. JOGL's release jars are signed already--by Sun--but you will need to sign any jars you make. This leads to the error

JAR resources in JNLP file are not signed by same certificate

Luckily, Google found a nice discussion here: http://forum.java.sun.com/thread.jspa?threadID=615425&messageID=342149. In short, you can work around the problem by using the tag in your JNLP file. To use the default jogl jars, use simply this:

<resources>
...
<extension name="jogl" href="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp"/>
</resources>

The downside is of course you are now a slave to the JOGL archives. If you want to
guarantee the jogl jars used at download are the ones that are compatible with your compilation, you will need to work out your own salvation. First, change the extension URL to your server in your JNLP file:

<resources>
<extension name="jogl-stuff" href="http://your.host.com/your-app/jogl-stuff.jnlp"/>
</resources>

Then create your extension JNLP. The easiest way to do this is to cheat: use the wget command (on linux/unix) to grab the "official" JOGL JNLP and then edit it.

[shell-prompt> wget http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp

After editing, your jogl-stuff.jnlp file will look something like

<?xml version="1.0" encoding="utf-8"?>
<jnlp codebase="http://your.server.com/your-app" href="jogl-stuff.jnlp">
<information>
<title>JOGL</title>
<vendor>Sun Microsystems, Inc.</vendor>
<homepage href="http://jogl.dev.java.net/"/>
<description>JOGL - JSR-231 Current Build</description>
<description kind="short">Java programming language binding for the OpenGL 3D graphics API. (Current build of JSR-231 APIs)</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<jar href="jogl.jar" />
</resources>
<resources os="Windows" arch="x86">
<nativelib href = "jogl-natives-win32.jar" />
</resources>
<resources os="SunOS" arch="sparc">
<nativelib href = "jogl-natives-solsparc.jar" />
</resources>
<resources os="SunOS" arch="x86">
<nativelib href = "jogl-natives-solx86.jar" />
</resources>
<resources os="Linux" arch="i386">
<nativelib href = "jogl-natives-linux.jar" />
</resources>
<resources os="Linux" arch="x86">
<nativelib href = "jogl-natives-linux.jar" />
</resources>
<resources os="Mac OS X" arch="i386">
<nativelib href = "jogl-natives-macosx.jar" />
</resources>
<component-desc />
</jnlp>

No comments: