Creating the Stubs and Skeletons

As mentioned earlier, JVMs in the 1.4 or earlier versions of Java require that you generate stub/skeleton classes using the RMI compiler. Once the interface and implementation classes have been compiled using the standard Java compiler, the RMI compiler (rmic, in the Sun JDK) is used to generate the stub and skeleton classes depicted earlier in Figure 13-1. In its simplest form, you can run rmic with the fully qualified class name of your implementation class as the only argument. For example, once we’ve compiled the Account and AccountImpl classes, we can generate the stubs and skeletons for the remote Account object with the following command (Unix version):

        % rmic AccountImpl

If the RMI compiler is successful, this command generates the stub and skeleton classes, AccountImpl_Stub and AccountImpl_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, and so on. 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 AccountImpl

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 Appendix F.

Get Java Enterprise in a Nutshell, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.