The JWS Portal Page


A JWS Installer for Checkers3D

I'll go through the six installer development steps again, this time for the Checkers3D application. Checkers3D was the first Java 3D example considered in Chapter 15.

Figure B-9. The JWS portal page


Write the Application

Checkers3D uses the OpenGL Windows version of Java 3D, and so requires:

j3daudio.jar

j3dcore.jar

j3dutils.jar

vecmath.jar

JAR files

J3D.dll

j3daudio.dll

J3DUtils.dll

Native libraries

They must be copied into the Checkers3D/ directory, resulting in Figure B-10.

The compileChk.bat batch file contains this line:

     javac -classpath "%CLASSPATH%;vecmath.jar;j3daudio.jar;                              j3dcore.jar;j3dutils.jar" *.java 

The Checkers3D.bat batch file has this:

     java -cp "%CLASSPATH%;vecmath.jar;j3daudio.jar;                          j3dcore.jar;j3dutils.jar" Checkers3D 

Figure B-10. The initial Checker3D/ directory


Once the program has been tested, the application should be packaged as a JAR. The makeJar.bat batch file has this line to handle that:

     jar cvmf mainClass.txt Checkers3D.jar *.class 

The manifest details in mainClass.txt are:

     Main-Class: Checkers3D     Class-Path: vecmath.jar j3daudio.jar j3dcore.jar j3dutils.jar 

The application now consists of eight files:

  • The application JAR file: Checkers3D.jar

  • Four Java 3D JAR files: j3daudio.jar, j3dcore.jar, j3dutils.jar, and vecmath.jar

  • Three native libraries: J3D.dll, j3daudio.dll, and J3DUtils.dll

  • And a partridge in a pear tree (no, I'm joking about that one).

These should be moved to a different directory on a different machine and tested. Double-clicking on Checkers3D.jar should start the application.

Modify the Application for Deployment

The three DLLs must be placed inside their own JARs:

     jar cvf J3DDLL.jar J3D.dll     jar cvf j3daudioDLL.jar j3daudio.dll     jar cvf J3DUtilsDLL.jar J3DUtils.dll 

The main( ) method of Checkers3D must be modified to call System.loadLibrary( ) for the three DLLs:

     public static void main(String[] args)     {       // DLLs used by Java 3D extension       String os = System.getProperty("os.name");       if (os.startsWith("Windows")) {         System.out.println("Loading '" + os + "' native libraries...");         System.out.print("  J3D.dll... ");         System.loadLibrary("J3D");  // drop ".dll"         System.out.println("OK");             System.out.print("  j3daudio.dll... ");         System.loadLibrary("j3daudio");         System.out.println("OK");             System.out.print("  J3DUtils.dll... ");         System.loadLibrary("J3DUtils");         System.out.println("OK");       }       else {         System.out.println("Sorry, OS '" + os + "' not supported.");         System.exit(1);       }           new Checkers3D(  );     } // end of main(  ) 

Create a Public/Private Keypair for Signing the Application

A new keypair is generated in the keystore:

   keytool -genkey -keystore MyKeyStore -alias Checkers3D 

Sign Everything with the Private Key

For the Checkers3D application, there are (now) eight JAR files:

Checkers3D.jar

The application JAR file

j3daudio.jar

j3dcore.jar

j3dutils.jar

vecmath.jar

Four JAVA 3D JAR files

J3DDLL.jar

j3daudioDLL.jar

J3DUtilsDLL.jar

Three native-library JARs

The Sun JAR files are copied and signed with these commands:

     jarsigner -keystore MyKeyStore -signedjar j3daudio_signed.jar                                                      j3daudio.jar  Checkers3D     jarsigner -keystore MyKeyStore -signedjar j3dcore_signed.jar                                                      j3dcore.jar Checkers3D     jarsigner -keystore MyKeyStore -signedjar j3dutils_signed.jar                                                      j3dutils.jar Checkers3D     jarsigner -keystore MyKeyStore -signedjar vecmath_signed.jar                                                      vecmath.jar Checkers3D 

The DLL JAR files are signed in place:

     jarsigner -keystore MyKeyStore J3DDLL.jar Checkers3D     jarsigner -keystore MyKeyStore j3daudioDLL.jar Checkers3D     jarsigner -keystore MyKeyStore J3DUtilsDLL.jar Checkers3D 

The manifest information in mainClass.txt is changed to reference these signed files:

     Main-Class: Checkers3D     Class-Path: vecmath_signed.jar j3daudio_signed.jar                                       j3dcore_signed.jar j3dutils_signed.jar 

Finally, after Checkers3D.jar is regenerated, it is signed:

     jarsigner -keystore MyKeyStore Checkers3D.jar Checkers3D 

Create a Deployment File

The deployment file for the Checkers3D application, Checkers3D.jnlp, is shown in Example B-3.

Example B-3. Deployment file for Checkers3D
     <?xml version="1.0" encoding="utf-8"?>     <!-- Checkers3D Deployment -->         <jnlp spec="1.0+"       codebase="file:///D:/Teaching/Java Games/Code/JWS/Checkers3D/"       href="Checkers3D.jnlp"       >           <information>         <title>Checkers3D</title>         <vendor>Andrew Davison</vendor>         <homepage href="http://fivedots.coe.pcu.ac.th/~ad/jg"/>         <description>Checkers3D</description>         <description kind="short">Checkers3D: a simple java 3D example             showing a blue sphere above a checkboard.</description>         <icon href="chess32.gif"/>         <icon kind="splash" href="startBanner.gif"/>         <offline-allowed/>       </information>           <security>         <all-permissions/>       </security>           <resources os="Windows">         <j2se version="1.4+"/>         <jar href="Checkers3D.jar" main="true"/>             <jar href="j3daudio_signed.jar"/>         <jar href="j3dcore_signed.jar"/>         <jar href="j3dutils_signed.jar"/>         <jar href="vecmath_signed.jar"/>             <nativelib href="J3DDLL.jar"/>         <nativelib href="j3daudioDLL.jar"/>         <nativelib href="J3DUtilsDLL.jar"/>       </resources>           <application-desc main-/>     </jnlp> 

At this stage, codebase is pointing to a local directory. The icons and splash screen images, chess32.gif and startBanner.gif, must be placed in the Checkers3D/ directory. The resources section lists eight JAR files.

Double-clicking on Checkers3D.jnlp should initiate JWS and the installation process, as shown in Figure B-11.

Figure B-11. Checkers3D installation


The dialog box in Figure B-12 appears at the point when the application should start executing.

Checkers3D suffers from the "highly recommended not to install and run this code" message since it uses a self-signed certificate just like BugRunner.

Figure B-12. Execute at your peril (again)


Place Everything on a Server

Now move the folowing 11 Checkers3D files to your server:

  • Checkers3D.jnlp

  • Checkers3D.jar

  • j3daudio.jar, j3dcore.jar, j3dutils.jar, and vecmath.jar

  • J3DDLL.jar, j3daudioDLL.jar, and J3DUtilsDLL.jar

  • chess32.gif and startBanner.gif

Checkers3D.jnlp must be modified to have its codebase use the server's URL:

     codebase="http://fivedots.coe.psu.ac.th/~ad/jws/Checkers3D/" 

The Checkers3D/ directory is placed below jws/ on the server, as shown in Figure B-13.

Figure B-13. The Checkers3D directory on the server


Clicking on the Checkers3D link on the JWS portal page (see Figure B-13) will cause it to be downloaded, with JWS showing the same dialogs as in Figures B-11 and B-12.

Before starting this phase, any previous installation of Checkers3D should be removed via the JWS application manager.



Killer Game Programming in Java
Killer Game Programming in Java
ISBN: 0596007302
EAN: 2147483647
Year: 2006
Pages: 340

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net