Sei sulla pagina 1di 2

//Concatenator.java interface Concatenator extends java.rmi.Remote { public int fact(int a) throws java.rmi.RemoteException; //Concatenator!mpl.java public class Concatenator!

mpl extends java.rmi.server."nicastRemote#bject implements Concatenator { public Concatenator!mpl() throws java.rmi.RemoteException { super(); public int fact( int a) throws java.rmi.RemoteException { int fact$%; for(int i$%;i&$a;i'') {fact$fact(i; return fact;

// Client.java import java.rmi.)amin*; import java.io.(; import java.util.(; import java.rmi.RemoteException; import java.net.+alformed"R,Exception; import java.rmi.)ot-oundException; public class Client { public static void main(.trin*/0 ar*s) { tr1 { Concatenator c $ (Concatenator) )amin*.loo2up(3rmi4//localhost/Concatenator.ervice3); .canner s$ new .canner(.1stem.in); .1stem.out.println(3enter a number to calculate a factorial3); .1stem.out.flush(); int n$ s.next!nt(); .1stem.out.println(35actoral of an entered no is3); .1stem.out.println( c.fact(n) ); catch (+alformed"R,Exception murle) { .1stem.out.println(murle); catch (RemoteException re) { .1stem.out.println(re);

catch ()ot-oundException nbe) { .1stem.out.println(nbe); catch ( java.lan*.6rithmeticException ae) { .1stem.out.println(ae);

// .erver.java import java.rmi.)amin*; public class .erver { public .erver() { tr1 { Concatenator c $ new Concatenator!mpl(); )amin*.rebind(3rmi4//localhost4%788/Concatenator.ervice39 c); catch (Exception e) { .1stem.out.println(3:rouble4 3 ' e);

public static void main(.trin* ar*s/0) { new .erver();

Potrebbero piacerti anche