forked from patniemeyer/learningjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyClient.java
More file actions
27 lines (24 loc) · 747 Bytes
/
Copy pathMyClient.java
File metadata and controls
27 lines (24 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//file: MyClient.java
import java.rmi.*;
import java.util.*;
public class MyClient {
public static void main(String [] args)
throws RemoteException {
new MyClient( args[0] );
}
public MyClient(String host) {
try {
RemoteServer server = (RemoteServer)
Naming.lookup("rmi://"+host+"/NiftyServer");
System.out.println( server.getDate( ) );
System.out.println(
server.execute( new MyCalculation(2) ) );
} catch (java.io.IOException e) {
// I/O Error or bad URL
System.out.println( e );
} catch (NotBoundException e) {
// NiftyServer isn't registered
System.out.println( e );
}
}
}