import java.rmi.Naming; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; public class ServerOperation extends UnicastRemoteObject implements RMIInterface{ protected ServerOperation() throws RemoteException {} public String mult(int number) throws RemoteException{ int [] a = new int[5]; String output1=""; for(int i=0; i<=4; i++){ a[i]= (i+1)*number; output1= output1+" "+a[i]; } return "The 5 multiples of " +number+" are"+ output1; } public String div(int number) throws RemoteException{ int [] b = new int[number]; String output2=""; for(int i=1; i<=number; i++){ if (number%i==0){ b[i-1]= i; output2= output2+" "+b[i-1]; } } return "The divisor(s) of " +number+" are"+ output2 ; } public static void main(String[] args){ try { Naming.rebind("//localhost/MyServer", new ServerOperation()); System.out.println("Server ready"); } catch (Exception e) { System.err.println("Server exception: " + e.toString()); e.printStackTrace(); } } }