Java Reference
In-Depth Information
Table 9-1. Manifest Attributes
Attribute
Use
Manifest-Version
Specifies which version of the Manifest.mf definition you are
conforming to. At present only version 1.0 has been defined.
Created-By
Specifies the jar tool's creator and version number. This is
automatically added by the jar tool itself, so you should not set it.
Class-Path
You may optionally use this to specify libraries needed at runtime.
These must be specified relative to the current JAR file (so you can
specify lib/another.jar but you cannot specify an absolute path like
d:\libs\another.jar ). If you have multiple JAR files, separate them
by spaces.
Main-Class
Tells the JVM which class to execute if the JVM is started with the -jar
parameter.
There are many other attributes that can be set as well, but delving into them is beyond
the scope of this topic. If you are interested in reviewing these options, we recommend you
look at the Sun documentation for JAR files available online at http://java.sun.com/j2se/
1.5.0/docs/guide/jar/jar.html#JAR Manifest .
The jar tool needs to know where to load the manifest file so that it can be included in the
JAR file. Otherwise, the jar tool will create one by default. The manifest file that is created by
default when you do not specify one will not include a main class label.
Running rmic on the Remote Package
One of the benefits of using JDK 5 is that using rmic to create stubs is not strictly necessary;
the stubs can be generated dynamically. However, as explained in Chapter 6, stubs are still
required if you have pre-JDK 5 clients or if you are not allowed to dynamically generate stubs.
This section has been provided for the benefit of those who may require stubs.
Caution At the time of this writing, all current assignments have a prohibition against requiring the
dynamic downloading of stubs—you must provide all stubs precompiled in your executable JAR file. Since
dynamically generating stubs would result in the stubs being dynamically downloaded, you cannot use the
JDK 5 dynamic stub generation feature. However, you should still check the assignment instructions you
downloaded from Sun; future assignments may remove this prohibition.
Using RMI involves creating stubs with the Java tool rmic . The stubs need to be packaged
up with the JAR file in order to run the program using RMI via the remote package.
The rmic command only needs to be run on the remote object implementation class
file. In our case, that class is DvdDatabaseImpl of the remote package. Make sure you run the
rmic command from the destination directory because the class files are required by rmic .
Figure 9-4 shows rmic being run against the DvdDatabaseImpl class. In addition, rmic also
needs to be run against the DvdDatabaseFactoryImpl class.
Search WWH ::




Custom Search