Guest User

Untitled

a guest
Jan 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. import java.rmi.*;
  2. import java.rmi.registry.*;
  3. import java.rmi.server.*;
  4. import java.util.Date;
  5.  
  6. public class myRMIClient
  7. {
  8. public static void main(String[] argv)
  9. {
  10. System.setSecurityManager(new RMISecurityManager());
  11. if (argv.length != 1)
  12. {
  13. System.out.println("usage: java myRMIClient <IP address of host running RMI server>");
  14. System.exit(0);
  15. }
  16. String serverName = argv[0];
  17. try
  18. {
  19. //bind server object to object in client
  20. myRMIInterface myServerObject = (myRMIInterface) Naming.lookup("rmi://"+serverName+"/myRMIImplInstance");
  21.  
  22. //invoke method on server object
  23. Date d = myServerObject.getDate();
  24. System.out.println("Date on server is " + d);
  25. }
  26. catch(Exception e)
  27. {
  28. System.out.println("Exception occured: " + e);
  29. System.exit(0);
  30. }
  31. System.out.println("RMI connection successful");
  32. }
  33.  
  34.  
  35. }
Add Comment
Please, Sign In to add comment