3.3. Creating the Stubs and Skeletons
After you define the remote Java interface and implementation class, you compile them into Java bytecodes using a standard Java compiler. Then you use the RMI stub/skeleton compiler, rmic, to generate the stub and skeleton interfaces that are used at either end of the RMI communication link, as was shown in Figure 3-1. In its simplest form, you can run rmic with the fully qualified classname of your implementation class as the only argument. For example, once we've compiled the ThisOrThatServer and ThisOrThatServerImpl classes, we can generate the stubs and skeletons for the remote ThisOrThatServer object with the following command (Unix version):
% rmic ThisOrThatServerImpl
If the RMI compiler is successful, this command generates the stub and skeleton classes, ThisOrThatServerImpl_Stub and ThisOrThatServerImpl_Skel, in the current directory. The rmic compiler has additional arguments that let you specify where the generated classes should be stored, whether to print warnings, etc. For example, if you want the stub and skeleton classes to reside in the directory /usr/local/classes, you can run the command using the -d option:
% rmic -d /usr/local/classes ThisOrThatServerImpl
This command generates the stub and skeleton classes in the specified directory. A full description of the rmic utility and its options is given in Chapter 9, RMI Tools.
Copyright © 2001 O'Reilly & Associates. All rights reserved.