Create Desktop Applications with Java-Based Web Technologies
Pages: 1, 2, 3, 4, 5, 6
Launching the Server
So we've got a working application. It's now possible to launch the application from the command line with a simple command.
java -classpath :./lib/bootstrap.jar:./lib/ant.jar:./lib/catalina-
ant.jar:./lib/catalina.jar:./lib/commons-beanutils.jar:./lib/commons-
collections.jar:./lib/commons-digester.jar:./lib/commons-fileupload-1.0-
beta-1.jar:./lib/commons-logging-api.jar:./lib/commons-
logging.jar:./lib/commons-modeler.jar:./lib/jakarta-regexp-
1.2.jar:./lib/jasper-compiler.jar:./lib/jasper-runtime.jar:./lib/mx4j-
jmx.jar:./lib/mx4j.license:./lib/naming-common.jar:./lib/naming-
factory.jar:./lib/naming-resources.jar:./lib/servlet.jar:./lib/servlets-
cgi.renametojar:./lib/servlets-common.jar:./lib/servlets-
default.jar:./lib/servlets-invoker.jar:./lib/servlets-
manager.jar:./lib/servlets-ssi.renametojar:./lib/servlets-
webdav.jar:./lib/tomcat-coyote.jar:./lib/tomcat-http11.jar:./lib/tomcat-
jk.jar:./lib/tomcat-jk2.jar:./lib/tomcat-util.jar:./lib/tomcat-warp.jar:.
onjava.TomcatWrapper
OK, so that's a bit of a joke. Go ahead, send this to a customer and see how it flies. Unless your customer is a Java developer, you'll going to get some pretty strange looks.
It's a lot more reasonable to package these files up into a simple installer for the user. To accomplish this, we'll turn to the free version of the ZeroG InstallAnywhere product.
Note: One thing I've done here is put all of the various JAR files
into a single lib directory, which means that some of the typical Tomcat CLASSPATH
gradations are thrown out; for our purposes, that's fine. For "real-world" usage, it
may make sense to merge these JARs as an integrated "platform" release,
perhaps using Ant to crack and then rebuild a single merged JAR file. Or
even better, build a system for managing and tracking the latest release
versions (although that does get us closer to emulating the "DLL Hell"
problem one sees on Windows).
Building the Installer
After downloading, installing, and launching, you'll be presented with a wizard for setting up your installer, as shown in Figure 4.

Figure 4. InstallAnywhere Now! New Project
Name your project, as shown in Figure 5.

Figure 5. Product Name
Add your various supporting files, as shown in Figure 6.

Figure 6. Adding Files
You'll then be prompted to set the application's main() class. InstallAnywhere will auto-detect the classes with main() methods (as shown in Figure 7). We're going to point InstallAnywhere at onjava.TomcatWrapper for our application, which you can enter manually.

Figure 7. Finding main()
In the next panel, you'll set the CLASSPATH for the application, as shown in
Figure 8. You'll note that I've deselected the WAR file.

Figure 8. Setting the CLASSPATH
Finally, in Figure 9, you'll see the options for building the various installers. You can download various virtual machines as files from InstallAnywhere's web site and have a single installer build multiple versions. You'll note that I'm building a Windows installer, complete with bundled JVM, on a Mac OS X system. Before you click Build, however, click on the Advanced Designer button to switch the wizard to the interactive installer builder.

Figure 9. Build Targets (Simple)