[英]java.rmi.server.ExportException: remote object implements illegal remote interface
[英]Exception “remote object implements illegal remote interface”?
我在Java中使用rmi。 但是有一个ExportException“远程对象实现了非法的远程接口”。
这是我的代码,愿有人帮帮我吗?
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();
}
}
Remote
接口中的每个方法都必须能够抛出RemoteException
。 你的界面应该是:
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;
}
您可能需要查看RMI教程 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.