-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathClient.java
More file actions
34 lines (31 loc) · 875 Bytes
/
Client.java
File metadata and controls
34 lines (31 loc) · 875 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
29
30
31
32
33
34
import com.jamal.MyRemote;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
/**
* rmi
* 2019/9/27 15:39
* client
*
* @author 曾小辉
**/
public class Client {
public static void main(String[] args) {
new Client().go();
}
public void go(){
try {
Registry registry = LocateRegistry.getRegistry(2100);
MyRemote service = (MyRemote) registry.lookup("hello");
// MyRemote service = (MyRemote) Naming.lookup("rmi://localhost:10999/hello");
System.out.println(service.hello());
} catch (NotBoundException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
}
}