Create the server process.
The server creates object(s) of the above implementation class and registers them
with a naming service called the registry . It does this by using static method rebind
of class Naming (from package java.rmi ). This method takes two arguments:
• a String that holds the name of the remote object as a URL with protocol rmi ;
• a reference to the remote object (as an argument of type Remote ).
The method establishes a connection between the object’s name and its reference.
Clients will then be able to use the remote object’s name to retrieve a reference
to that object via the registry.
The URL string, as well as specifying a protocol of rmi and a name for the
object, specifi es the name of the remote object’s host machine. For simplicity’s
sake, we shall use localhost (which is what RMI assumes by default anyway). The
default port for RMI is 1099, though we can change this to any other convenient port
if we wish. The code for our server process is shown below and contains just one
method: main . To cater for the various types of exception that may be generated,
this method declares that it throws Exception .