title: Accessing RMI Server
body: <p>I would like to access an existing RMI server. I do not have access to its source code, so I would like to set up a client that calls an existing service in the RMI Server.</p>
  
  <p>What is the best way to create a client to invoke a particular method and can RMI be converted to a webservice?</p>
  
  <p>Below is the class I have created:</p>
  
  <pre><code>package server;
  
  import com.SerialService;
  import java.rmi.Naming;
  
  public class NewClass {
  
      public static void main(String args[]) {
          //SerialService obj = null;
          try {
  
              SerialService obj = (SerialService) Naming.lookup("//localhost:8083/");
              System.out.println(obj.getSerial());
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>