title: Example of a rmi program involving 2 machine connected via LAN
body: <p>I am trying to learn concepts of rmi in java. I succesfully run it in my machine and tried out to do it on two machine but failed.
  Server.java has</p>
  
  <pre><code>System.setSecurityManager(new RMISecurityManager());
          Addition Hello = new Addition();    
          Registry registry = LocateRegistry.createRegistry(5432);
          //Addition stub = (Addition) UnicastRemoteObject.exportObject(Hello,6789);
          registry.rebind("lookupthis", Hello);
          System.out.println("Addition Server is ready.");
  </code></pre>
  
  <p>Client.java has</p>
  
  <pre><code>Registry reg=LocateRegistry.getRegistry("[ip of server]",5432);
              hello = (AdditionalInterface)Naming.lookup("lookupthis");
              int result=hello.Add(9,10);
              System.out.println("Result is :"+result);
  </code></pre>
  
  <p>What changes i have to make it work for two machines. </p>
  
  <p>Please help me with this, Thanks in Advance</p>