Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.rmi.Naming;
- import java.rmi.RemoteException;
- import java.rmi.RMISecurityManager;
- public class RmiClient {
- // "obj" is the reference of the remote object
- RmiServerIntf obj = null;
- public String getMessage() {
- try {
- obj = (RmiServerIntf)Naming.lookup("//localhost/RmiServer");
- return obj.getMessage();
- } catch (Exception e) {
- System.err.println("RmiClient exception: " + e);
- e.printStackTrace();
- return e.getMessage();
- }
- }
- public static void main(String args[]) {
- // Create and install a security manager
- if (System.getSecurityManager() == null) {
- System.setSecurityManager(new RMISecurityManager());
- }
- RmiClient cli = new RmiClient();
- System.out.println(cli.getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement