I use rmi in Java. however there is a ExportException "remote object implements illegal remote interface".
Here is my code, May someone help me?
public interface RemotePeer extends Remote {
public abstract void displayInf(String inf);
public abstract void exit();
public abstract boolean isActive();
}
public class Peer implements RemotePeer{
public Peer(){}
....
public static void main(String[] args) {
Peer p=new Peer()
RemotePeer remoteP=(RemotePeer) UnicastRemoteObject.exportObject(p, 0);
Registry registry = LocateRegistry.getRegistry();
}
}
Every method in a Remote
interface must be able to throw a RemoteException
. Your interface should be:
public interface RemotePeer extends Remote {
public abstract void displayInf(String inf) throws RemoteException;
public abstract void exit() throws RemoteException;
public abstract boolean isActive() throws RemoteException;
}
You might want to take a look at the RMI Tutorial.