首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >人机界面实例与ExportException

人机界面实例与ExportException
EN

Stack Overflow用户
提问于 2013-10-25 20:59:00
回答 1查看 66关注 0票数 0

大家好!我有问题,我的RMI例子。一周前,我尝试着开始我的第一个RMI示例,它成功了,但我删除了项目,并尝试再次创建,但我不能,因为‘抛出ExportException’。我做错什么了?也许我需要重新启动rmiregistry.exe或者别的什么?

代码语言:javascript
复制
public interface IExample extends Remote {
    public String getMessage(String input) throws RemoteException;
}

public class ExampleImpl extends UnicastRemoteObject implements IExample {
    public ExampleImpl() throws RemoteException {
        super();
    }

    @Override
    public String getMessage(String input) throws RemoteException {
        return "Hi " + input + "!!!";
    }
  public static void main(String... args) throws RemoteException, MalformedURLException {
        System.setSecurityManager(new RMISecurityManager());
        String name = "myexample";
        IExample engine = new ExampleImpl();
        IExample stub =
                (IExample) UnicastRemoteObject.exportObject(engine, 1090);
        Registry registry = LocateRegistry.getRegistry();
        registry.rebind(name, stub);
}
}

附注:谢谢大家,为我的英语道歉。P.p.s.还有我愚蠢的问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-25 21:34:05

扩展UnicastRemoteObject的类在构造时自动导出。你不必自己动手。删除exportObject()调用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19599331

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档