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:
NervousText06BeanInfo class (subclass SimpleBeanInfo)
getBeanDescriptor method
getPropertyDescriptors method
I am just doing steps 2,5, and 6 to illustrate the use and specification of packages and making the jar file
package sun.beanbox.beans;
import java.beans.*;
public class NervousText06BeanInfo
extends SimpleBeanInfo {
...
}
javac -d . NervousText06.java
javac -d . NervousText06BeanInfo.java
OR
For your information:
javac -classpath .:/home/avh/classes:/usr/local/java/classes ...
javac -d /home/avh/classes MyProgram.javacauses the compiled class files for the classes in the
MyProgram.java source file to be saved in the directory
/home/avh/classes. If your classes are defined in the
package demos/awt, the class files would be placed in
the directory /home/avh/classes/demos/awt.
Note that the -d and -classpath options have independent effects. The compiler reads only from the class path, and writes only to the destination directory. It is often useful for the destination directory to be on the class path. If the -d option is not specified, the source files should be stored in a directory hierarchy which reflects the package structure, so that the resulting class files can be easily located.
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/