Hi,
I always hated making a webstart application until I realized I could add some custom ant targets to the build.xml file of my netbeans project. The ant file creates the self signed certificate (doesn’t need to be executed each time), compiles the main class (and any other classes that might be needed) and finally signs the resulting jar.
The first target creates a new certificate :
generatekey target (build.xml in Files tab in Netbeans) :
<target name="generatekey">
<genkey alias="dae" storepass="yourpassword" >
<dname>
<param name="CN" value="Hogeschool Westvlaanderen"/>
<param name="OU" value="Digital Arts And Entertainment"/>
<param name="O" value="http://www.howest.be"/>
<param name="C" value="BE"/>
</dname>
</genkey>
</target>
The second target compiles the program, creates the jar file and signs it :
(I compile from the main class, so I only add the class files I really need for the demo. Off course it’s possible to compile the whole project)
<target name="buildsoar" depends="-post-init,-do-clean">
<mkdir dir="${build.classes.dir}"/>
<javac classpath="${javac.classpath}" srcdir="${src.dir}"
destdir="${build.classes.dir}" includes="dae/objects/landscape/LandscapeTest.java" target="1.5"/>
<copy todir="${build.classes.dir}">
<fileset dir="${src.dir}">
<include name="**/*.ter"/>
</fileset>
</copy>
<mkdir dir="webstart"/>
<jar basedir="${build.classes.dir}"
destfile="webstart/soar.jar">
<manifest>
<attribute name="Main-Class" value="dae/objects/landscape/LandscapeTest"/>
</manifest>
</jar>
<signjar jar="webstart/soar.jar" signedjar="webstart/ssoar.jar" alias="dae" storepass="yourpassword"/>
</target>
That’s all there is to it, it’s also possible to add a target that ftp’s the resulting jar file (and jnlp file) to your webserver of choice. You can invoke the two targets by right clicking on the build.xml file.
For completeness the jnlp file :
<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for SwingSet2 Demo Application -->
<jnlp
spec="1.0+"
codebase="http://home.euphonynet.be/xanadu/soar"
href="soar.jnlp">
<information>
<title>Soar Demo</title>
<vendor>Digital Arts & Entertainment,University of Westflanders</vendor>
<description>An implementation of the SOAR algorithm</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.5+"/>
<jar href="ssoar.jar" main="true"/>
[b]<extension name="jogl" href="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp" />[/b]
</resources>
<application-desc main-class="dae.objects.landscape.LandscapeTest"/>
</jnlp>
An important line in the jnlp file is in bold. with the extension tag you can use the jogl jnlp file (which is properly signed). Using the extension has 2 important advantages :
-
Users that have allready used another webstart application that uses the extension don’t have to download the jogl jars.
-
The jogl extension defines all the platform specific resources (dll’s and so’s specifically).
Result (shameless plug to my terrain engine demo ) : Soar demo
hth,
Koen Samyn