Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
JavaFX 2.0.2 and successor SDKs let you deploy JavaFX applications in multiple environments including as a standalone app, via Java Web Start, or embedded in a web page. Jeff Friesen follows up his recent introduction to JavaFX 2.0 with this short tip on deploying JavaFX applications.
If you've read my three-part introduction to JavaFX 2.0, then you will be familiar with JPadFX, the Swing-based notepad that I used as a refactoring example for that series. Even if you're not familiar with JPadFX, you should be able to follow this tip. We'll concentrate on deploying the application, so you won't need to know much about its internals. Do go ahead and download JPadFX now.
Source files for the JPadFX app are
AreYouSure.java, and the resource file
icon.png. Once you have extracted these files to your current directory, execute the following command to compile the app on Windows:
javac -cp "C:\Program Files\Oracle\JavaFX 2.0 SDK\rt\lib\jfxrt.jar";. -d out JPadFX.java
I assume that you have installed the JavaFX 2.0.2 SDK to
C:\Program Files\Oracle\JavaFX 2.0 SDK. Also,
-d out stores the resulting class files in a subdirectory named
JavaFX 2.0.2 provides a command-line tool,
javafxpackager, that makes application deployment almost a snap. On my Windows XP platform,
javafxpackager is installed in the
C:\Program Files\Oracle\JavaFX 2.0 SDK\bin directory.
Once you have compiled JPadFX's source files, use
javafxpackager to package the class files and JavaFX Launcher (a small set of classes that finds the installed JavaFX runtime and invokes the main application class via the runtime) into
a JAR file as follows:
javafxpackager -createjar -appclass JPadFX -srcdir out -outdir out -outfile jpadfx.jar -v
Note the options specified in Listing 1:
javafxpackagerto create a JAR file.
JPadFXas the main class for the JAR manifest and JavaFX Launcher.
outas the directory containing the class files.
outas the directory in which to create the JAR file.
jpadfx.jaras the name of the JAR file.
If the previous command succeeds, you will need to introduce
jpadfx.jar. A simple way to do this is to use the JDK's
jar tool. Assuming that the current directory contains
icon.png and the
out subdirectory, execute the following command to store
jar uf out\jpadfx.jar icon.png
At this point, you might want to try running JPadFX in standalone mode in order to test the JAR file's veracity. First, switch
out directory (which contains
jpadfx.jar) and execute a command similar to the following:
java -cp "C:\Program Files\Oracle\JavaFX 2.0 SDK\rt\lib\jfxrt.jar";. -jar jpadfx.jar
This command adds
java's classpath, which contains JavaFX class files that the JVM needs to load at runtime.
More from JavaWorld