152 DB2 Deployment Guide
Deployment procedure for a Java application
The procedure for deploying a Java application is simple and straightforward.
These are the steps involved:
1. Package the application along with the IBM Data Server Driver. Include the
Java runtime environment if required.
2. Copy the files to the target environment.
3. Make sure that the path and classpath are set up correctly.
We use an example to discuss the general idea of how to deploy a Java
application with the IBM Data Server Driver and the Java runtime environment.
Both the Java runtime environment and the IBM Data Server Driver are files that
can simply be copied along with your application. No specific install program is
required for any of them. We build a directory structure containing all the files and
then package this directory structure in a portable format. This can be a tar file on
Linux and UNIX or a zip file on Windows. For demonstration purposes, we use
the Windows environment and generate a self-extracting executable.
We use a Java sample application, MigrateExecuter, described in 5.6, “Samples
overview” on page 251 as the application to be deployed. The application is
packaged in the Java archive file itso.jar. In the Java environment, we have to
specify where to find the Java runtime environment, and we have to set up the
Java classpath, which tells the Java runtime environment where to find
components. We use the command file jmigrate.cmd to do this.
Example 4-2 shows the working directory where we assemble our deployment
structure.
Example 4-2 Deployment structure for our Java application
26-06-2008 21:34 <DIR> db2
26-06-2008 21:27 <DIR> jre1.6.0_05
20-06-2008 08:52 39.784 itso.jar
26-06-2008 21:49 619 jmigrate.cmd
In the DB2 directory, the files from the IBM Data Server Driver are located. These
are db2jcc.jar, db2jcc4.jar, sqlj.zip, and sqlj4.zip. The Java runtime environment
is copied to the subdirectory jrel.6.0.0_05. This working directory is then
compressed and extended into the self-extractable executable appjava.exe by
using WinZip. Our basic requirement is to copy all our files to a user-selected
directory. The use of WinZip is not required, but is used for convenience. We
deploy our application by executing appjava.exe and selecting a target directory
for the installation. We are now ready to test our deployed application. We do this
by executing jmigrate.cmd. A few key lines of the command file are listed in
Example 4-3.