-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRMIClient.java
More file actions
28 lines (24 loc) · 776 Bytes
/
Copy pathRMIClient.java
File metadata and controls
28 lines (24 loc) · 776 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
28
import java.rmi.*;
import java.rmi.registry.*;
public class RMIClient {
public static void main(String[] args) {
String text = "RMI Test Message";
RMIInterface rmi = null;
try {
Registry registry = LocateRegistry.getRegistry("127.0.0.1", 1099);
rmi = (RMIInterface) registry.lookup("server");
System.out.println("Connected to Server");
} catch (Exception e) {
e.printStackTrace();
}
if (rmi != null) {
try {
rmi.sendMessage(text);
System.out.println(rmi.getMessage(text));
} catch (RemoteException e) {
e.printStackTrace();
}
System.out.println("Finished");
}
}
}