Java Reference
In-Depth Information
If the bean contains a main method, the fi rst line of the manifest will use a Main-
Class specifi er to name the containing class, followed by a blank line. The manifest
for our animation bean is as follows:
Main-Class: AnimBean1
Name: animBeans/AnimBean1.class
Java-6: True
All that needs to be explained now before looking at full command lines that
will create JAR fi les is the meaning of the fi rst parameter supplied to the jar utility
(the options parameter). 'Options' are single letters that appear consecutively. The
possible values for such options are c , f , m , t , v , x and 0 . The meanings of these
values are shown in Table 10.1 .
Table 10. 1 Option values for the jar utility
Create a new JAR fi le
If combined with 'c', specifi es that fi le to be created is named on command line;
if used with 't' or 'x', specifi es that an existing fi le is named
Use manifest fi le named on command line
List table of contents for JAR fi le
'Verbose' output: generate additional output (fi le sizes, etc.)
Extract fi le named on command line or, if none specifi ed, all fi les in directory
Suppress compression of fi les
1 . jar cmf MyBean.jar *.class
(Creates a JAR fi le called MyBean.jar containing all .class fi les in the current
directory and allocates manifest fi le to the JAR fi le.)
2 . jar tf OldBean.jar
(Lists the contents of OldBean.jar .)
Assuming (i) that our manifest fi le is called , (ii) that we are
executing the jar utility from the folder that holds the manifest fi le, (iii) the bean
folder is immediately below the current folder and (iv) we wish to call our JAR fi le
Animation1.jar , the required command line is:
jar cmf Animation1.jar animBeans\
Note the use of a backslash for the Windows platform here, but the use of a
forward slash in the manifest fi le! It is very easy to make a slip with this.
Having packaged our bean, we can open it up in an IDE (if our IDE has such a
facility) or send the JAR fi le across a network. More commonly, we will probably
leave the bean unpackaged and make use of it within an application. This will be
covered in Sect. 10.4 , but fi rst we need to consider the mechanism for making use
of a bean's properties.
Search WWH ::

Custom Search