import java.rmi.*;
import java.rmi.server.*;

  public class MyServerImpl extends UnicastRemoteObject
  implements MyServer {
  
  static String hostName="localhost";
  static String data[] = {"Remote","Method","Invocation","Is","Great!"};
  
  public MyServerImpl() throws RemoteException {
    super();
  }
  
  public int getDataNum() throws RemoteException {
    return data.length;
  }
  
  public String getData(int n) throws RemoteException {
    return data[n%data.length];
  }
  
  public static void main(String args[]){
    try {
      MyServerImpl instance = new MyServerImpl();
      Naming.rebind("//"+hostName+"/MyServer", instance);
      System.out.println("I'm registered!");
    } catch (Exception ex) {
      System.out.println(ex);
    }
  }
}