A convenient way to ensure that all modules of a Java routine are accessible is to
store those modules in a JAR file. You create the JAR file by running
the jar
command in z/OS®
UNIX System Services.
Before you begin
For a JDBC routine, before you can create a JAR file, you
need to compile the source code. For an SQLJ routine, before you can
create a JAR file, you need to translate, compile, and customize the
source code.
Procedure
- If the Java source
file does not contain a
package
statement, change
to the directory that contains the class file for the Java routine, which you created by running the
javac command. For example, if JDBC routine Add_customer.java
is in /u/db2res3/acmejos, change to directory /u/db2res3/acmejos.
If
the Java source file contains
a package
statement, change to the directory that
is one level above the directory that is named in the package
statement.
For
example, suppose the package statement is:
package lvlOne.lvlTwo.lvlThree;
Change
to the directory that contains lvlOne as an immediate subdirectory.
- Run the
jar
command. You
might need to specify at least these options:
- c
- Creates a new or empty archive.
- v
- Generates verbose output on
stderr
.
- f
- Specifies that the argument immediately after the options list
is the name of the JAR file to be created.
For example, to create a JAR file named acmejos.jar
from Add_customer.class, which is in package acmejos, execute this jar
command:
jar -cvf acmejos.jar acmejos/Add_customer.class
To
create a JAR file for an SQLJ routine, you also need to include all
generated class files, such as classes that are generated for iterators,
and all serialized profile files. For example, suppose that all classes
are declared to be in package acmejos, and all class files, including
generated class files, and all serialized profile files for SQLJ routine
Add_customer.sqlj are in directory /u/db2res3/acmejos/. To create
a JAR file named acmejos.jar, change the the /u/db2res3 directory,
and then issue this jar
command:
jar -cvf acmejos.jar acmejos/*.class acmejos/*.ser