The RMI Registry
Home ] Up ] Remote Objects ] Remote Method Calls ] Components ] [ The RMI Registry ] A Simple Example ] Listing Remote Objects ] Extended Example ] Caveats ] Passing Objects in RMI ] Remote Callbacks ]

 

 

However, before we can actually perform a remote method invocation, we have one more thing to accomplish:

How do we locate the remote object?

The RMI library provides a bootstrap registry service through which the remote object may register itself, and then subsequently be located.

There are a number of different ways in which the registry may be accessed. We'll see some of them as we go through the examples.

The RMI Registry must be up and running before the server/remote object can start up and register itself, and before the client can locate the remote object.  

The JDK supplies a utility, rmiregistry which must be run to start the service -- that is, it must be run before you can perform any remote method invocations. 

 Click here for a synopsis of the rmiregistry command.

  • On Windows, it is recommended that you use the command:
    start rmiregistry [port]
  • On Unix/Linux, it is recommended that you use the command:
    rmiregistry [port] &
In both cases, this causes the command to be run in the background, with any potential error messages appearing in the associated console window.

(Naturally, the above commands assume that the rmiregistry executable directory location is included in the PATH.)

The default port number used by the RMI Registry is 1099, but you can override that (for example, if that port is already in use) by specifying the port number explicitly.

Note: A peculiar restriction appears to be the case for rmiregistry

You must start the program in the directory which forms the top of your classes hierarchy. (In NetBeans, that will be your project's Build/classes subdirectory.)

You must ensure that you start the program with no class path and in a directory with no class files.

If you fail to do this, your server will fail in its startup, with a mysterious error about not being able to find the remote interface.

There is a reason for this strange behavior;  see http://java.sun.com/j2se/1.5.0/docs/guide/rmi/codebase.html .

 
The page was last updated February 19, 2008