Filename: rint.java
import java.io.*;
import java.rmi.*;
public interface rint extends Remote
{
public int add(int a,int b)throws RemoteException;
publicintsub(intx,inty)throwsRemoteException;
public int mul(int p,int q)throws RemoteException;
}
File Name: rclass.java
importjava.io.*;
import java.rmi.*;
import java.net.*;
import java.rmi.server.*;
public class rclass extends UnicastRemoteObject implements rint
{
publicrclass()throwsRemoteException{}
publicintadd(inta,intb)throwsRemoteException
{
intc=a+b;
returnc;
}
publicintsub(intx,inty)throwsRemoteException
{
intd=x-y;
returnd;
}
publicintmul(intp,intq)throwsRemoteException
{
inte=p*q;
returne;
}
}
File Name: sclass.java
Importjava.io.*;
import java.rmi.*;
import java.net.*;
public class sclass
{
public static void main(String args[ ])
{
try
{
rclass r=new rclass();
Naming.rebind("sum",r);
}
catch(Exceptione){}
}
}
Filename: cclass.java
import java.io.*;
import java.rmi.*;
public class cclass
{
public static void main(String args[])
{
try
{
int b,b1;
Strings;
s="rmi://localhost/sum";
rintx=(rint)Naming.lookup(s);
b=Integer.parseInt(args[0]);
b1=Integer.parseInt(args[1]);
intz=x.add(b,b1);
intz1=x.sub(b,b1);
int z2=x.mul(b,b1);
System.out.println("Sum"+z);
System.out.println("Difference"+z1);
System.out.println("Product"+z2);
}
catch(Exceptione){ }
}
}
OUTPUT
Sum 4
Difference 0
Production 4
do u have program using rpc for sorting
ReplyDeleteIt's rmi or rpc
ReplyDelete