Java Reference
In-Depth Information
A common problem I always see with the jar tool is that it does not seem
to read the last line in a manifest file. Therefore, after you type the
following in your movie.mf file, hit Enter a couple of times so that the last
line of the manifest file is a blank line:
Java-Bean: True
This is important because if the Java-Bean line is not read by the jar tool,
the builder tool will think that Movie.class is not a JavaBean. If you don't
see the Movie bean in the list of available beans in the tool, check the
manifest file first.
Step 3: Create the JAR File
After you have written the manifest file, you are ready to create a JAR file for
your bean. We will use the jar tool that comes with the J2SE SDK. Open a com-
mand prompt and change directories to the directory containing the
Movie.java and movie.mf files. Then, enter the following jar command:
jar -cvfm movie_bean.jar movie.mf .\video
Figure 19.3 shows the output of this command.
I want to make a couple of comments about the jar command in Figure 19.3:
The f and m flags are for filename and manifest filename, respectively.
Placing the f before the m denotes that you specify the new filename
before the name of the manifest file, which was done in Figure 19.3.
■■
The file Movie.class is in a directory named \video\store because it is
in a package named video.store. Therefore, the \video\store directory
must appear in the JAR file. Adding the directory .\video adds all its
subdirectories, so notice in Figure 19.3 that this included the
Movie.class file in the appropriate directory structure.
■■
Figure 19.3
A JAR file named movie_bean.jar is created using the movie.mf manifest file.
Search WWH ::




Custom Search