I decided to write RMI (from the book) took code from the book too. i created the Stub with rmic, and started rmiregistry but when i dedided to write java Start Server i got the problem, actually here is my problem i faced with: java -classpath D:\RMI AddServer Exception:java.rmi.ServerException: RemoteException occurred in server thread; n ested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested excep tion is: java.lang.ClassNotFoundException: AddServerImpl_Stub PLease i need help, i lost lot of time because of this :(
AddServerIntf.java
package rmi.app;
import java.rmi.*;
public interface AddServerIntf extends Remote {
double add(double d1,double d2) throws RemoteException;}
AddServerImpl
package rmi.app;
import java.rmi.*;
import java.rmi.server.*;
public class AddServerImpl extends UnicastRemoteObject implements AddServerIntf {
public AddServerImpl() throws RemoteException {}
public double add(double d1, double d2) throws RemoteException {
return d1+d2;
}
}
AddServer
package rmi.app;
import java.net.*;
import java.rmi.*;
public class AddServer {
public static void main(String[] args) {
try {
AddServerImpl addServerImpl = new AddServerImpl();
Naming.rebind("AddServer", addServerImpl);
}
catch (Exception e){
System.out.println("Exception:"+e);
}
}
}
AddClient
package rmi.app;
import java.rmi.Naming;
public class AddClient {
public static void main(String[] args) {
try{
String addServerURL= "rmi://"+args[0]+ "/AddServer";
AddServerIntf addServer =(AddServerIntf)Naming.lookup(addServerURL);
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:"+ addServer.add(d1,d2));
}
catch(Exception e){
System.out.println("Exception : "+ e);
}
}
}