ProblemYou need to package your bean for deployment. Solution"Pickle your bean into a JAR," that is, create a JAR archive containing it and a manifest file. DiscussionIn addition to the compiled file, you need a manifest prototype, which needs only the following entries: 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 Recipe 23.4). Because the JAR file must contain the class files in their correct package location (see Recipe 23.1), and because LabelText is part of my com.darwinsys package (see Recipe 1.5), 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 =3D 1607) (out=3D 776)(deflated 51%) $ Now we're ready to install labeltext.jar as a JavaBean. However, the curious may wish to examine 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 upon 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.) Java-Bean: true Name: LabelText.class Not much exciting has happened besides the addition of a few lines. But the class is now ready for use as a JavaBean. For a GUI builder, either copy it into the beans directory or use the bean installation wizard, as appropriate. See AlsoMany good books on JavaBeans technology are available. O'Reilly's entry is Developing JavaBeans by Robert Englander. You can also find information on JavaBeans at Sun's web site, http://java.sun.com/products/javabeans/. |