I am new to java RMI, i was following a tutorial to learn about it. It uses a server, the code listing is as below for getting to the server
CalculatorServer.java
public class CalculatorServer { public CalculatorServer(){ try { Calculator c = new CalculatorImpl(); Naming.rebind("rmi://localhost:1099/CalculatorService", c); } catch (Exception e) { System.out.println("Trouble"+e); } } public static void main(String args[]){ new CalculatorServer(); } }
CalculatorImpl.java
public class CalculatorImpl extends UnicastRemoteObject implements Calculator { //constructor public CalculatorImpl() throws RemoteException { super(); } //@Override public long add(long a, long b) throws RemoteException { return a + b; } //@Override public long sub(long a, long b) throws RemoteException { return a - b; } //@Override public long mul(long a, long b) throws RemoteException { return a * b; } // @Override public long div(long a, long b) throws RemoteException { return a / b; } }
3.Calculator.java
public interface Calculator extends Remote{
public long add(long a, long b) throws RemoteException;
public long sub(long a, long b) throws RemoteException;
public long mul(long a, long b) throws RemoteException;
public long div(long a, long b) throws RemoteException;
}
When i debug the program, here is the error by netbeans ide console; it says this error : Troublejava.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: rmi.Calculator