Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.rmi.*;
- import java.rmi.registry.*;
- import java.rmi.server.*;
- import java.util.Date;
- public class myRMIClient
- {
- public static void main(String[] argv)
- {
- System.setSecurityManager(new RMISecurityManager());
- if (argv.length != 1)
- {
- System.out.println("usage: java myRMIClient <IP address of host running RMI server>");
- System.exit(0);
- }
- String serverName = argv[0];
- try
- {
- //bind server object to object in client
- myRMIInterface myServerObject = (myRMIInterface) Naming.lookup("rmi://"+serverName+"/myRMIImplInstance");
- //invoke method on server object
- Date d = myServerObject.getDate();
- System.out.println("Date on server is " + d);
- }
- catch(Exception e)
- {
- System.out.println("Exception occured: " + e);
- System.exit(0);
- }
- System.out.println("RMI connection successful");
- }
- }
Add Comment
Please, Sign In to add comment