Java Reference
In-Depth Information
try {
int sum = rmi - example - server.add (18, 34);
System.err.println ("According to the remote add(), the "
+ "sum of18and34is" +sum);
}
catch (RemoteException re) {
System.err.println (re);
}
} // ctor
public static void main (String[] args) {
new RMIExampleClient ();
} // main
} // class RMIExampleClient
That finishes all the code. The steps to compile and run are summarized as
follows:
1. Compile everything.
2. Run the rmic compiler.
3. Package the client code into a client JAR file.
4. Start the RMI registry.
5. Start the server.
6. Run the client.
We detail each of the steps below.
18.6.1 Compile everything
For all the client/server examples in this topic, we find it convenient to use the Ant
build tool, though describing Ant is not within the scope of this topic (see [1]). The
We b Course contains Ant build files as well as Windows bat scripts for building
each example. For simplicity we show only the Windows bat scripts here. Unix
shell scripts are very similar.
Ant strongly encourages a directory structure in which the compiled class
files are kept separate from the source files. An advantage of this arrangement is
that directory listings in the source directories are not cluttered up with a lot of
compiled .class files. We use that directory arrangement here, even though we
demonstrate building and running the examples with Windows bat scripts only.
Accordingly, all our source files and directories appear below a directory named
src . The name is completely arbitrary but is a common one for Ant users.
Therefore, at some top level directory containing everything pertinent to this
example, there is a src subdirectory. Below src appears javatech/rmi18/
server , for the interface file, javatech/rmi18/server/impl , for the
 
Search WWH ::




Custom Search