ShowCircle
and ShowSphere
Java programsShowCircle
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.
sandbox
directory in D:\Users\Peter
and set it as the current directorymkdir sandbox cd sandbox
ShowCircle
as a Java Swing 2D applicationsandbox
,
using a plain-text editor of your choice.
(Notepad++ is recommended.)net/havercan/geometry2D
directory and put ShowCircle.class
into itjavac -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.
sandbox
.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.)
jar tvf ShowCircle.jar
jar xf ShowCircle.jar META-INF/MANIFEST.MF type META-INF\MANIFEST.MF
java -jar ShowCircle.jar
sandbox
.sandbox
.net/havercan/geometry3D
directory by compiling ShowSphere.class
into itjavac -d . -g ShowSphere.java
ShowSphere
manifest filesandbox
.jar cvfm ShowSphere.jar ShowSphere.mf net/havercan/geometry3D/ShowSphere.class
jar tvf ShowSphere.jar
jar xf ShowSphere.jar META-INF/MANIFEST.MF type META-INF\MANIFEST.MF
java -jar ShowSphere.jar
sandbox
.file:///D:/Users/Peter/sandbox
and http://peter.havercan.net
to the Java Exception Site List.
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.