title: Difference between Naming and Registry in RMI
body: <p>I have used </p>
  
  <pre><code>Naming.rebind("rmi://localhost:1099/RmiServer", c);
  </code></pre>
  
  <p>where c is a remote object. And </p>
  
  <pre><code> XYZ robj=new XYZ();
   ABC stub = (ABC) UnicastRemoteObject.exportObject(robj, 0);
   Registry registry = LocateRegistry.getRegistry();
   registry.bind("RmiServer", stub);
  </code></pre>
  
  <p>where stub is the remote object.</p>
  
  <p>The first case is working fine if the rmiregistry is running already,but the later is throwing <code>ServerException that ClassNotFoundException</code> is thrown for ABC class. Where am i going wrong? </p>
  
  <p>Also how are <code>Naming and Registry different</code> in the sense that here Naming is binding to local host whereas later is getting the corresponding port and address dynamically and then binding the object to it. </p>