Login  Register

Re: JOGL applet deployment

Posted by Wade Walker on Jun 18, 2011; 8:37pm
URL: https://forum.jogamp.org/JOGL-applet-deployment-tp3074893p3080684.html

Here's how I did it for a local applet test, where it reads the files from disk, instead of through a web server. The web server version should be similar, I just haven't tried it yet.

I've tested this on Windows, Linux, and Mac, and it works fine everywhere except in Chrome and Firefox on Mac (see bug 497 at https://jogamp.org/bugzilla/show_bug.cgi?id=497).

I've zipped up this example (except for the JOGL JARs) at jws-example.zip. Note that some of the HTML and JNLP files contain filesystem paths. Just change those to your paths and it should work fine.

Now, the instructions:

- Copy all *-natives-*.jar files for all platforms into a directory.
- Copy the JAR with your code in it into the same directory (mine is onetriangle.jar).
- Copy applet-launcher.jar, gluegen-rt.jar, jogl.all.jar, nativewindow.all.jar, and newt.all.jar into the same directory. You can cut these down to take less space, but that's an advanced topic
- Create a key with "keytool -genkey -keystore testKeys -alias myalias"
- Sign all JARs (yours and JOGLs) with "jarsigner -keystore testKeys my.jar myalias"
- Create an applet HTML file. Mine looks like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>OneTriangle Applet Test</title>
</head>
<body>

<P>
Test of OneTriangle as an applet.
</P>

<P>

<applet code="org.jdesktop.applet.util.JNLPAppletLauncher"
      width=600
      height=400
      archive="applet-launcher.jar,
               newt.all.jar,
               nativewindow.all.jar,
               jogl.all.jar,
               gluegen-rt.jar,
               onetriangle.jar">
   <param name="codebase_lookup" value="false">
   <param name="subapplet.classname" value="name.wadewalker.jogl2tests.onetriangle.OneTriangleAWTApplet">
   <param name="subapplet.displayname" value="OneTriangle Applet">
   <param name="noddraw.check" value="true">
   <param name="progressbar" value="true">
   <param name="jnlpNumExtensions" value="1">
   <param name="jnlpExtension1" value="JOGL.jnlp">
   <param name="java_arguments" value="-Dsun.java2d.noddraw=true">
   <param name="jnlp_href" value="OneTriangleApplet.jnlp">
</applet>

</P>

<P>
The applet should be above this.
</P>

</body>
</html>


- Create an applet JNLP file. Mine looks like this:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="file://localhost/D:/Users/Wade/Documents/Blog/jws/"
  href="OneTriangleApplet.jnlp">

  <information>
    <title>OneTriangle Demo</title>
    <vendor>JogAmp Community</vendor>
    <homepage href="http://jogamp.org/"/>
    <description>OneTriangle Demo</description>
    <description kind="short">The simplest possible JOGL demo - draws one triangle.</description>
    <offline-allowed/>
  </information>
  <update check="background" policy="always"/>

  <security>
    <all-permissions/>
  </security>

  <resources>
    <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
    <property name="sun.java2d.noddraw" value="true"/>
    <extension name="JOGL" href="JOGL.jnlp" />
    <jar href="onetriangle.jar" main="true"/>
  </resources>

  <applet-desc 
      name="OneTriangleApplet"
      main-class="name.wadewalker.jogl2tests.onetriangle.OneTriangleAWTApplet"
      width="600" 
      height="400">
  </applet-desc>
</jnlp>

- Create a JOGL JNLP file. It has to be in a separate file because of a limitation of applet-launcher.jar. Mine looks like this:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="file://localhost/D:/Users/Wade/Documents/Blog/jws/"
  href="JOGL.jnlp">

  <information>
    <title>JOGL libraries</title>
    <vendor>JogAmp Community</vendor>
    <homepage href="http://jogamp.org/"/>
    <description>JOGL libraries</description>
    <description kind="short">All JARs and native libraries for JOGL.</description>
    <offline-allowed/>
  </information>
  <update check="background" policy="always"/>

  <security>
    <all-permissions/>
  </security>

  <resources>
    <jar href="gluegen-rt.jar" />
    <jar href="nativewindow.all.jar" />
    <jar href="jogl.all.jar" />
    <jar href="newt.all.jar" />
  </resources>

  <resources os="Windows" arch="x86">
    <nativelib href = "gluegen-rt-natives-windows-i586.jar" />
    <nativelib href = "jogl-natives-windows-i586.jar" />
    <nativelib href = "nativewindow-natives-windows-i586.jar" />
    <nativelib href = "newt-natives-windows-i586.jar" />
  </resources>
  <resources os="Windows" arch="amd64">
    <nativelib href = "gluegen-rt-natives-windows-amd64.jar" />
    <nativelib href = "jogl-natives-windows-amd64.jar" />
    <nativelib href = "nativewindow-natives-windows-amd64.jar" />
    <nativelib href = "newt-natives-windows-amd64.jar" />
  </resources>
  <resources os="Windows" arch="x86_64">
    <nativelib href = "gluegen-rt-natives-windows-amd64.jar" />
    <nativelib href = "jogl-natives-windows-amd64.jar" />
    <nativelib href = "nativewindow-natives-windows-amd64.jar" />
    <nativelib href = "newt-natives-windows-amd64.jar" />
  </resources>
  <resources os="Linux" arch="i386">
    <nativelib href = "gluegen-rt-natives-linux-i586.jar" />
    <nativelib href = "jogl-natives-linux-i586.jar" />
    <nativelib href = "nativewindow-natives-linux-i586.jar" />
    <nativelib href = "newt-natives-linux-i586.jar" />
  </resources>
  <resources os="Linux" arch="x86">
    <nativelib href = "gluegen-rt-natives-linux-i586.jar" />
    <nativelib href = "jogl-natives-linux-i586.jar" />
    <nativelib href = "nativewindow-natives-linux-i586.jar" />
    <nativelib href = "newt-natives-linux-i586.jar" />
  </resources>
  <resources os="Linux" arch="amd64">
    <nativelib href = "gluegen-rt-natives-linux-amd64.jar" />
    <nativelib href = "jogl-natives-linux-amd64.jar" />
    <nativelib href = "nativewindow-natives-linux-amd64.jar" />
    <nativelib href = "newt-natives-linux-amd64.jar" />
  </resources>
  <resources os="Linux" arch="x86_64">
    <nativelib href = "gluegen-rt-natives-linux-amd64.jar" />
    <nativelib href = "jogl-natives-linux-amd64.jar" />
    <nativelib href = "nativewindow-natives-linux-amd64.jar" />
    <nativelib href = "newt-natives-linux-amd64.jar" />
  </resources>
  <resources os="Mac OS X" arch="i386">
    <nativelib href = "gluegen-rt-natives-macosx-universal.jar" />
    <nativelib href = "jogl-natives-macosx-universal.jar" />
    <nativelib href = "nativewindow-natives-macosx-universal.jar" />
    <nativelib href = "newt-natives-macosx-universal.jar" />
  </resources>
  <resources os="Mac OS X" arch="x86_64">
    <nativelib href = "gluegen-rt-natives-macosx-universal.jar" />
    <nativelib href = "jogl-natives-macosx-universal.jar" />
    <nativelib href = "nativewindow-natives-macosx-universal.jar" />
    <nativelib href = "newt-natives-macosx-universal.jar" />
  </resources>

  <component-desc />
</jnlp>

Then double-click on your applet HTML file and watch it run!