Bonjour, je commence à travailler avec RMI, et j'ai trouver ce code client sur le net, mais, quant je l'execute, il m'affiche l'erreur : Usage : HelloClient host venant de l’exception : ArrayIndexOutOfBoundsException. J'ai pas compris pourquoi et je ne sais pas comment la résoudre. Pourriez vous m'aider
Remarque : le client dois afficher 'hello' venant du serveur.
Merci d'avance!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
35
36 import java.net.MalformedURLException; import java.rmi.Naming; import java.rmi.NotBoundException; import java.rmi.RemoteException; public class HelloClient { public static void main(String[] args) { String url = null; Hello hello = null; try { url = "rmi://" + args[0] + ":1099/Hello"; hello = (Hello) Naming.lookup(url); } catch (MalformedURLException e) { System.err.println("l'URL " + url + "est incorrecte"); System.exit(1); } catch (RemoteException e) { System.err.println( "Avez-vous lancé le rmiregistry ?"); System.exit(2); } catch (NotBoundException e) { System.err.println( "Avez-vous lancé le serveur ?"); System.exit(2); } catch (ArrayIndexOutOfBoundsException e) { System.err.println( "Usage : HelloClient host"); System.exit(3); } try { System.out.println(hello.sayHello()); } catch (RemoteException e) { System.err.println("le serveur semble down"); System.exit(4); } } }
Partager