Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Packages within JAR files can be optionally sealed, which means that all classes defined in that package must be archived in the same JAR file. You might want to seal a package, for example, to ensure version consistency among the classes in your software.You seal a package in a JAR file by adding the Sealed header in the manifest, which has the general form:
The value myCompany/myPackage/ is the name of the package to seal.Name: myCompany/myPackage/ Sealed: trueNote that the package name must end with a "/".
We want to seal two packages firstPackage and secondPackage in the JAR file MyJar.jar.We first create a text file named Manifest.txt with the following contents:
Name: myCompany/firstPackage/ Sealed: true Name: myCompany/secondPackage/ Sealed: trueWe then create a JAR file named MyJar.jar by entering the following command:
Warning: The text file must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.This creates the JAR file with a manifest with the following contents:jar cmf Manifest.txt MyJar.jar MyPackage/*.classManifest-Version: 1.0 Created-By: 1.5.0_01 (Sun Microsystems Inc.) Name: myCompany/firstPackage/ Sealed: true Name: myCompany/secondPackage/ Sealed: true
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.