Content deleted Content added
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags |
fix some broken refs |
||
Line 43:
try { //special exception handler for registry creation
LocateRegistry.createRegistry(1099);
System.out.println("java RMI registry created.");
} catch (RemoteException e) {
Line 68:
public interface RmiServerIntf extends Remote {
String getMessage() throws RemoteException;
}
</syntaxhighlight>
'''<code>RmiClient</code> class''' — this is the client which gets the reference (a proxy) to the remote object living on the server and invokes its method to get a message. If the server object implemented java.io.Serializable instead of java.rmi.Remote, it would be serialized and passed to the client as a value.<ref>
<syntaxhighlight lang=java>
import java.rmi.Naming;
public class RmiClient {
public static void main(String args[]) throws Exception {
RmiServerIntf server = (RmiServerIntf)Naming.lookup("//localhost/RmiServer");
System.out.println(server.getMessage());
}
}
|