non-static method add(double,double) cannot be referenced from a static context
while working the RMI program, i saw the erroe message " non-static method add(double,double) cannot be referenced from a static context".
the program is:
interfare pgm:
import java.rmi.*;
public interface intf extends Remote
{
double add(double d1,double d2) throws RemoteException;
}
implementation pgm:
import java.rmi.*;
import java.rmi.server.*;
public class impl extends UnicastRemoteObject implements intf
{
public impl() throws RemoteException
{}
public double add(double d1,double d2)throws RemoteException
{
return d1+d2;
}
}
server pgm:
import java.rmi.*;
import java.net.*;
public class serv
{
public static void main(String args[])
{
try
{
impl implref=new impl();
Naming.rebind("serv",implref);
}
catch(Exception e)
{
System.out.println("Exception:"+e);
}
}
}
client pgm:
import java.rmi.*;
public class clie
{
public static void main(String args[])
{
try
{
String surl="rmi://"+args[0]+"/serv";
intf intfref=(intf)Naming.lookup(surl);
System.out.println("the first number is:"+args[1]);
double d1=Double.valueOf(args[1]).doubleValue();
System.out.println("the second number is:"+args[2]);
double d2=Double.valueOf(args[2]).doubleValue();
System.out.println("the sum is:" + intf.add(d1,d2));
}
catch(Exception e)
{
System.out.println("Exception:"+e);
}
}
}
plz tell the correction as soon as possible.
i am waiting for the result.............