University of Cincinnati logo and link  
Getting the Stub, Finding the Server
 
  UC ingotWe can either manually copy the stub to the client, or we can get it dynamically.  But first we need to get some reference to the server.
    • The bootstrap registry service in the RMI library allows us to get this initial reference to the server.  The server must register objects with this service by giving the service an object and a unique name.
    • Thus, or server must have something like:

    • ChatImpl chatImpl = new ChatImpl();
      Naming.bind("chatme", chatImpl);
    • And our client should follow with:

    • Chat c = (Chat) Naming.lookup("rmi://localhost/chatme");
  • Some very important notes:
    • Note that the server, in our case, ChatServer, instantiates a ChatImpl object and sends the object to Naming's bind method.  Note the responsibilities of ChatServer and ChatImpl in this context.
    • Note that bind and lookup are static methods of class Naming.
    • The URL is composed of:
      • rmi:// the protocol name, rmi, followed by ://
      • localhost substitute your host name for this, or use localhost if you are testing both the client and the server on the same machine.
      • chatme the name that was bound in class Naming.


 Starting the Server