Preparation of the ShowCircle and ShowSphere Java programs

ShowCircle and ShowSphere are prepared as two very simple Java programs to demonstrate the difference in deployment between an applet and a JavaFX application. ShowCircle is a Java Swing JApplet, and ShowSphere is a JavaFX 3D scene-based application. In this example they are created with exactly parallel construction using the JNLP architecture for both. The JNLP archicture requires that the program is built into a JAR File before use. In fact, applets can be deployed more directly without using JNLP or JARs, but the aim of this demonstration is to highlight the parallels.

Notice that no IDE is used is used to manage the source files. This is so that details of the IDE management do not obscure the actual requirements for deployment.

Note that these instructions document how I believe that deployment of JavaFX programs as browser applets is supposed to work. In fact, I have not yet successfully managed to do this. The best that can be done is to deploy such a program as a local Java application using Java Web Start, which is what the JNLP architecture was originally invented for.

The following instructions describe how I prepared these programs on Windows 7.

Create the sandbox directory in D:\Users\Peter and set it as the current directory
mkdir sandbox
cd sandbox

Prepare ShowCircle as a Java Swing 2D application
Edit the java program ShowCircle.java in sandbox, using a plain-text editor of your choice. (Notepad++ is recommended.)
Create the net/havercan/geometry2D directory and put ShowCircle.class into it
javac -d . -g ShowCircle.java

The -d . option causes a directory structure corresponding to the package specification in the code to be created relative to the current directory. The -g option generates debug information.

Prepare a manifest file for inclusion in the JAR file
Edit the manifest file ShowCircle.mf in sandbox.
Create the ShowCircle JAR file
jar cvfm ShowCircle.jar ShowCircle.mf net/havercan/geometry2D/ShowCircle*.class

(The wildcard * is specified in the class name to ensure all subclasses are included.)

Inspect the created JAR file
jar tvf ShowCircle.jar
Optionally, extract the manifest file and view it
jar xf ShowCircle.jar META-INF/MANIFEST.MF
type META-INF\MANIFEST.MF
Confirm that the JAR file is executable
java -jar ShowCircle.jar
Prepare the JAR file for execution as a browser applet using the JNLP protocol
Edit ShowCircle.jnlp and ShowCircle.html in sandbox.

Prepare ShowSphere as a JavaFX 3D application
Edit the java program ShowSphere.java in sandbox.
Create the net/havercan/geometry3D directory by compiling ShowSphere.class into it
javac -d . -g ShowSphere.java
Prepare the ShowSphere manifest file
Edit the manifest file ShowSphere.mf in sandbox.
Create the JAR file
jar cvfm ShowSphere.jar ShowSphere.mf net/havercan/geometry3D/ShowSphere.class
Inspect the created JAR file
jar tvf ShowSphere.jar
Optionally, extract the manifest file and view it
jar xf ShowSphere.jar META-INF/MANIFEST.MF
type META-INF\MANIFEST.MF
Confirm that the JAR file is executable
java -jar ShowSphere.jar
Now prepare the JAR file for execution as a browser applet using the JNLP protocol
Edit ShowSphere.jnlp and ShowSphere.html in sandbox.

Export all the files to the target web server
All the relevant jar, JNLP, and HTML files are exported to peter.havercan.net/sandbox.
Configure Java Security to allow the programs to be executed as browser applets
Add file:///D:/Users/Peter/sandbox and http://peter.havercan.net to the Java Exception Site List.
The gory details of configuring Java security are described in Java security setup for Windows 7.
Try out ShowCircle.html as an applet
If security is set correctly, this executes as expected and displays a blue disk in 2D.
Try out ShowSphere.html as an applet
If security is set correctly, this begins to deploy, but fails with the following error:

However, if the local application link on that page is used, the application launches correctly as a Java Web Start application, and displays a blue sphere in 3D. This shows that the application and the JNLP markup are both coded correctly. However, the message ExitException: JNLP not an applet, nor a JavaFX application seems to imply that deployment of a JavaFX application as an applet should be possible, and is intended, but that the Java plugin is not recognizing the jar file as a valid JavaFX application, even though it works as a Java Web Start program.