Commit | Line | Data |
---|---|---|
70d0d0e1 JB |
1 | package exemples.javarmi.hello; |
2 | import java.rmi.Naming; | |
3 | import java.rmi.RMISecurityManager; | |
4 | ||
5 | public class HelloClient { | |
6 | public static void main(String[] args){ | |
7 | /* lance le SecurityManager */ | |
8 | System.setSecurityManager(new RMISecurityManager()); | |
9 | try { | |
10 | String server = args[0]; | |
11 | int port = Integer.parseInt(args[1]); | |
12 | /* cherche référence objet distant */ | |
13 | HelloInterface hello = (HelloInterface)Naming.lookup("rmi://"+server+":"+port+"/Hello1"); | |
14 | /* appel de méthode à distance */ | |
15 | System.out.println(hello.sayHello()); | |
16 | } | |
17 | catch (Exception e) { | |
18 | System.out.println ("Erreur client : " + e); | |
19 | } | |
20 | } | |
21 | } |