import java.rmi.Naming;
import java.rmi.RemoteException;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;

public class XCliente {

 public static void main(String[] args) {
  try {
   // Es busca el servei ServicioX -- forward 
   X c = (X)Naming.lookup("rmi://localhost:1099/ServicioX");
   System.out.println( c.incr(4) );
   System.out.println( c.mesg("Luis") );
  }
  catch (MalformedURLException murle) {
   System.out.println("MalformedURLException: " + murle);
  }
  catch (RemoteException re) {
   System.out.println("RemoteException: " + re);
  }
  catch (NotBoundException nbe) {
   System.out.println("NotBoundException: " + nbe);
  }
  catch (java.lang.ArithmeticException ae) {
   System.out.println("java.lang.ArithmeticException: " + ae);
  }
 }
}


