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 37
|
public class ServeurClient
{
public static void main(String [] args)
{
if (args.length != 1)
{
System.out.println("Usage : java Serveur <port du rmiregistry>");
System.exit(0);
}
try
{// PARTIE SERVEUR
Fonctions objLocal = new Fonctions ();
Naming.rebind( "rmi://localhost:1000/myObject" ,objLocal) ;
System.out.println("Serveur pret");
// PARTIE CLIENT
Myfonction b=(Myfonction)Naming.lookup("rmi://"+args[0]+"/myObject" );
// ...
}
catch (NotBoundException re)
{
System.out.println(re) ;
}
}
catch (RemoteException re)
{
System.out.println(re) ;
}
catch (MalformedURLException e)
{
System.out.println(e) ;
}
}
} |
Partager