Creating a JAR File

Let’s package up the simulator classes in a JAR file. This will allow us to distribute the entire package in one unit, as well as to test the Beans using BeanBox. The first step is to create a manifest file called Simulator.mf, naming each class and specifying whether or not they are Beans. Marking a class as a Bean is meant to indicate that it qualifies as an object that exposes events, methods, and properties, and that it is a useful object in its own right. The listener interfaces and the event objects are useful, but they provide no useful function by themselves. The TemperatureModifier isn’t marked as a Bean; it is the abstract base class for the Cooler and Boiler Beans, and so can never be instantiated by itself. The manifest file looks as follows:

Manifest-Version: 1.0

Name: BeansBook/Simulator/Boiler.class
Java-Bean: True

Name: BeansBook/Simulator/Cooler.class
Java-Bean: True

Name: BeansBook/Simulator/CoolingRequestListener.class
Java-Bean: False

Name: BeansBook/Simulator/HeatingRequestListener.class
Java-Bean: False

Name: BeansBook/Simulator/ServiceRequestEvent.class
Java-Bean: False

Name: BeansBook/Simulator/Temperature.class
Java-Bean: True

Name: BeansBook/Simulator/TemperatureModifier.class
Java-Bean: False

Name: BeansBook/Simulator/TemperaturePulseEvent.class
Java-Bean: False

Name: BeansBook/Simulator/TemperaturePulseListener.class
Java-Bean: False

Name: BeansBook/Simulator/Thermostat.class
Java-Bean: True

Note that only the Boiler, Cooler, Temperature ...

Get Developing Java Beans now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.