Oracle8i SQLJ Developer's Guide and Reference Release 3 (8.1.7) Part Number A83723-01 |
Library | Service | Contents | Index

## Use of JAR Files for Profiles

As discussed previously, you can specify a `.jar` file on the SQLJ command line in to customize any profiles that the `.jar` file contains.

Notes: Remember that you can specify `.sqlj` and/or `.java` files on the SQLJ command line for normal SQLJ processing, or you can specify `.ser` and/or `.jar` files on the command line for customization only, but not both. It is permissible for the `.jar` file to contain files that are not profiles. Any file whose manifest entry indicates that the file is not a profile will be ignored during customization. The `.jar` file is used as the class-loading context for each profile it contains. If a profile contains a reference to a class contained within the `.jar` file, then that class is loaded from the `.jar` file. If a profile contains a reference to a class not in the `.jar` file, then the system class loader will find and load the class according to your `CLASSPATH`, as usual.

### JAR File Requirements

When using a `.jar` file for profiles, the manifest entry for each profile must contain the line:

    SQLJProfile: TRUE

Accomplish this by: 1) creating a plain text file with two lines for each profile that will be included in the `.jar` file--one line specifying the path or package and name, and one line as above; and 2) using the `jar` utility `-m` option to input this file.

The two lines must be consecutive (no blank line in between), and there must be a blank line preceding line-pairs for additional profiles.

For example, presume your `MyApp` application (in the directory `foo/bar`) has three profiles, and you will be creating a `.jar` file that will include these profiles. Complete the following steps:

1. Create a text file with the following eight lines (including the blank lines used as separators):

       Name: foo/bar/MyApp_SJProfile0.ser
       SQLJProfile: TRUE

       Name: foo/bar/MyApp_SJProfile1.ser
       SQLJProfile: TRUE

       Name: foo/bar/MyApp_SJProfile2.ser
       SQLJProfile: TRUE

   Presume you call this file `MyAppJarEntries.txt`

2. When you run `jar` to create the `.jar` file, use the `-m` option to input your text file as follows (presume you want to call the .`jar` file `myjarfile.jar`):

       jar -cvfm myjarfile.jar MyAppJarEntries.txt foo/bar/MyApp_SJProfile*.ser foo/bar/*.class

   As the `jar` utility constructs the manifest during creation of the `.jar` file, it reads your text file and inserts the `SQLJProfile: TRUE` line into the manifest entry of each profile. It accomplishes this by matching the names in the manifest with the names you specify in your text file.

### JAR File Results

When you specify a `.jar` file on the SQLJ command line, each profile in the `.jar` file is deserialized and customized.

A `.jar` file is successfully customized only if all the profiles it contains are successfully customized. After a successful customization, each profile has been reserialized into a `.ser` file, the `.jar` file has been modified to replace the original `.ser` files with the customized `.ser` files, and the `.jar` file manifest has been updated to indicate the new entries.

If any error is encountered in the customization of any profile in a `.jar` file, then the `.jar` file customization has failed, and the original `.jar` file is left completely unchanged.

Note: If you use signature files for authentication, the signature files that appeared in the original `.jar` file will appear unchanged in the updated `.jar` file. You are responsible for re-signing the new `.jar` file if the profiles require signing.

| Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
Library | Service | Contents | Index