0

Good day everybody! I have problem, with my RMI example. Week ago, i try to start my first example of RMI, and it's worked, but i delete project, and try to create again, but i can't,cos' throw ExportException. What did i do wrong? Maybe i need to restart rmiregistry.exe or something else?

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.s. Thx for all and sorry for my English. P.p.s. and for my stupid question.

4

1 回答 1

0

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

于 2013-10-25T21:34:05.313 回答