Making the Bean

I am copying this from a java tutorial to help me remember the steps. If you want to see what the whole thing was about, go there.

In their example, they did following steps:

I am just doing steps 2,5, and 6 to illustrate the use and specification of packages and making the jar file

Step 2. Create the skeletal form for the NervousText06BeanInfo class

    package sun.beanbox.beans;
    import java.beans.*;

    public class NervousText06BeanInfo
            extends SimpleBeanInfo {
        ...
    }

Step 5. Compile the programs

        javac -d . NervousText06.java

javac -d . NervousText06BeanInfo.java

OR

For your information:

Step 6. Build and install the JAR

Now you have two classes to add to your JAR file; one is a Bean, the other isn't. However, you only need one manifest and one JAR. The manifest should look like this:

    Manifest-Version: 1.0

    Name: sun/beanbox/beans/NervousText06.class
    Java-Bean: True

    Name: sun/beanbox/beans/NervousText06BeanInfo.class
A makefile will make the manifest for you if you don't want to do it by hand. It will also build the JAR file and copy it to the right location provided that you have set the target directories at the top of the file.
    echo "Manifest-Version: 1.0" > manifest.tmp
    echo "" >> manifest.tmp
    echo "Name: sun/beanbox/beans/NervousText06.class" 
         >> manifest.tmp
    echo "Java-Bean: True" >> manifest.tmp
    echo "" >> manifest.tmp
    echo "Name: sun/beanbox/beans/NervousText06BeanInfo.class" 
         >> manifest.tmp
    jar cfm NervousText06.jar manifest.tmp \
            sun/beanbox/beans/NervousText06.class \
            sun/beanbox/beans/NervousText06BeanInfo.class
    cp -p NervousText06.jar BDK_HOME/beans/jars

Be sure to substitute your BDK installation directory for BDK_HOME when you copy the JAR.

Of course you do not have to do all the echo business; just make a file called manifest.tmp and put in the stuff mentioned, then do

   
 jar cfm NervousText06.jar manifest.tmp sun/beanbox/beans/NervousText06.class sun/beanbox/beans/NervousText06BeanInfo.class

Some things that seemed to make a difference:
When I did it for the YesNoDialog class in Java in a Nutshell the manifest file did not like the

Manifest-Version: 1.0

in it. Here is what I ended up with for the manifest.tmp and the makefile . One final note. When you compile the code of a class that you have defined in a package, it will create the directory substructure for that package for the classes. Sepcifically, in this example, it creates the structure: oreilly/beans/yesno/

Do not give your package the same name (case sensitive) as your package name.

This has been found to cause nasty "unseeable" errors in that, well, nothing happens when you put your bean in a beanbox. The naming convention is to make packages all lower case, and class names with IndividualWords upper case as shown. I hope this was/is helpful!