//AddServer

import java.rmi.*;

public interface AddServer extends Remote

{

double add(double d1,double d2) throws RemoteException;

}

//Add Server Imp

import java.rmi.*;

import java.rmi.server.*;

public class AddServerImp extends UnicastRemoteObject implements AddServer

{

public AddServerImp() throws RemoteException

{

}

public double add(double d1,double d2) throws RemoteException

{

return d1+d2;

}

}

//Adds

import java.net.*;

import java.rmi.*;

public class Adds

{

public static void main(String args[])

{

try

{

AddServerImp addServerImp= new AddServerImp();

Naming.rebind(“Adds”,addServerImp);

}

catch(Exception e)

{

System.out.println(“Exception:”+e);

}

}

}

//AddClient

import java.rmi.*;

public class AddClient

{

public static void main(String args[])

{

try

{

String addServerURL=”rmi://localhost”+”/Adds”;

AddServer addserver=(AddServer)Naming.lookup(addServerURL);

System.out.println(“First number is:”+args[0]);

double d1=Double.valueOf(args[0]).doubleValue();

System.out.println(“Second number is:”+args[1]);

double d2=Double.valueOf(args[1]).doubleValue();

System.out.println(“The sum is:”+addserver.add(d1,d2));

}

catch(Exception e)

{

System.out.println(“Exception:”+e);

}

}

}