package rmi.rmiSynth;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class RMIClient {
public static void main(String args[]) {
try {
example();
} catch (Exception e) {
e.printStackTrace();
}
}
private static void example() throws RemoteException, NotBoundException {
RMIInterface rs = getProxy();
System.out.println(rs.getHello());
}
private static RMIInterface getProxy() throws RemoteException, NotBoundException {
Registry r = getRegistry();
RMIInterface rs = (RMIInterface) r.lookup(RMIInterface.SERVER_NAME);
return rs;
}
private static Registry getRegistry() throws RemoteException {
Registry r = LocateRegistry.getRegistry("localhost");
return r;
}
}