sách gpt4 ăn đã đi

java - 异常 "remote object implements illegal remote interface"?

In lại 作者:搜寻专家 更新时间:2023-10-30 19:50:16 28 4
mua khóa gpt4 giày nike

我在 Java 中使用 rmi。但是有一个 ExportException“远程对象实现非法远程接口(interface)”。

这是我的代码,有人可以帮帮我吗?

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();
}
}

câu trả lời hay nhất

Remote 接口(interface)中的每个方法都必须能够抛出 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 Tutorial .

关于java - 异常 "remote object implements illegal remote interface"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12654942/

28 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress