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