LookupRemote

import javax.naming.*;
import java.rmi.RemoteException;
import javax.rmi.PortableRemoteObject;


// JRMP: name = "rmi://localhost/RObjectServer";
// IIOP: name = "iiop://localhost/RObjectServer";
try {
    // Look up remote object
    Object obj = new InitialContext().lookup(name);

    // Cast to the appropriate type
    RObject robj = (RObject)PortableRemoteObject.narrow(obj, RObject.class);

    // Invoke method on remote object
    robj.aMethod();
} catch (NamingException e) {
} catch (RemoteException e) {
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.