A JWS Installer for Checkers3DI'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 pageWrite the ApplicationCheckers3D uses the OpenGL Windows version of Java 3D, and so requires: j3daudio.jar j3dcore.jar j3dutils.jar vecmath.jar
J3D.dll j3daudio.dll J3DUtils.dll
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/ directoryOnce 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:
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 DeploymentThe 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 ApplicationA new keypair is generated in the keystore: keytool -genkey -keystore MyKeyStore -alias Checkers3D Sign Everything with the Private KeyFor the Checkers3D application, there are (now) eight JAR files: Checkers3D.jar
j3daudio.jar j3dcore.jar j3dutils.jar vecmath.jar
J3DDLL.jar j3daudioDLL.jar J3DUtilsDLL.jar
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 FileThe 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 installationThe 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 ServerNow move the folowing 11 Checkers3D files to your server:
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 serverClicking 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. |