Java Reference
In-Depth Information
to the compiled file, you need a manifest prototype, which needs the following entries as a
minimum; you can also put such information as your vendor URL or a copyright notice:
Name: LabelText.class
Java-Bean: true
If these lines are stored in a file called LabelText.stub , we can prepare the whole mess for use
as a bean by running the jar command (see Archiving with jar ). Because the JAR file must
contain the class files in their correct package location (see Creating a Package ) , and because
LabelText is part of my com.darwinsys package (see Downloading and Using the Code
Examples ), I start off in the source directory and refer to the class file by its full path (the
Stub file can be anywhere, but I keep it with the source file so I can find it easily, thus I have
to refer to it by its full path, too):
$ cd $js/darwinsys/src
$ jar cvfm labeltext.jar com/darwinsys/swingui/LabelText.stub \
com/darwinsys/swingui/LabelText.class
added manifest
adding: com/darwinsys/swingui/LabelText.class(in=1607) (out=776)(deflated 51%)
$
Of course, in production you would want to automate this with a build tool such as Ant (see
Automating Compilation with Apache Ant ) or Maven (see Automating Dependencies, Com-
pilation, Testing, and Deployment with Apache Maven ) .
Now we're ready to install labeltext.jar as a JavaBean. However, the curious may wish to ex-
amine the JAR file in detail. The x option to jar asks it to extract files:
$ jar xvf labeltext.jar
created: META-INF/
extracted: META-INF/MANIFEST.MF
extracted: com/darwinsys/swingui/LabelText.class
$
The MANIFEST.MF file is based on the manifest file ( LabelText.stub ); let's examine it:
$ more META-INF/MANIFEST.MF
Manifest-Version: 1.0
Created-By: 1.4.2_03 (Apple Computer, Inc.)
Search WWH ::




Custom Search