agendaservice.java~21~

来自「ssd8 exercise 4 答案 老师写的, 绝对正确」· JAVA~21~ 代码 · 共 39 行

JAVA~21~
39
字号
package Exercise4;

import java.rmi.*;
import java.rmi.server.*;

public class AgendaService {
  public AgendaService() {
  }

  public static void main(String args[]) {
    System.out.println("loadin RMI service");

    try {
      SimpleAgenda myAgenda = new SimpleAgenda();
     // RemoteRef location = myAgenda.getRef();
      // System.out.println(location.remoteToString());
      if (System.getSecurityManager() == null) {
                   System.setSecurityManager(new RMISecurityManager());
               }

      String registry = "localhost";

      if (args.length >= 1) {
        registry = args[0];
      }

      String registration = "rmi://" + registry + ":" + args[1] + "/SimpleAgenda";
      System.out.println(registration);
      Naming.rebind(registration, myAgenda);
    }
    catch (RemoteException re) {
      System.err.println("Remote error : " + re);
    }
    catch (Exception e) {
      System.err.println("Error " + e);
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?