国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

我的RMI實(shí)踐

2019-11-18 12:42:00
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

  //: c15:rmi:PerfectTime.java
  // From 'Thinking in Java, 2nd ed.' by BrUCe Eckel
  // www.BruceEckel.com. See copyright notice in CopyRight.txt.
  // The implementation of
  // the PerfectTime remote object.
  import java.rmi.*;
  import java.rmi.server.*;
  import java.rmi.registry.*;
  import java.net.*;
  
  public class PerfectTime
  extends UnicastRemoteObject
  implements PerfectTimeI {
  // Implementation of the interface:
  public long getPerfectTime()
  throws RemoteException {
  return System.currentTimeMillis();
  }
  // Must implement constructor
  // to throw RemoteException:
  public PerfectTime() throws RemoteException {
  // super(); // Called automatically
  }
  // Registration for RMI serving. Throw
  // exceptions out to the console.
  public static void main(String[] args) throws Exception {
  PerfectTime pt = new PerfectTime();
  Naming.rebind("/PerfectTime", pt);
  System.out.  }
  } ///:~
  //: c15:rmi:PerfectTimeI.java
  // From 'Thinking in Java, 2nd ed.' by Bruce Eckel
  // www.BruceEckel.com. See copyright notice in CopyRight.txt.
  // The PerfectTime remote interface.
  import java.rmi.*;
  
  interface PerfectTimeI extends Remote {
  long getPerfectTime() throws RemoteException;
  } ///:~
  //: c15:rmi:DisplayPerfectTime.java
  // From 'Thinking in Java, 2nd ed.' by Bruce Eckel
  // www.BruceEckel.com. See copyright notice in CopyRight.txt.
  // Uses remote object PerfectTime.
  import java.rmi.*;
  import java.rmi.registry.*;
  
  public class DisplayPerfectTime {
  public static void main(String[] args)
  throws Exception {
  System.setSecurityManager(
  new RMISecurityManager());
  PerfectTimeI t = (PerfectTimeI)Naming.lookup("/PerfectTime");
  for(int i = 0; i < 10; i++)
  System.out.println("Perfect time = " +
  t.getPerfectTime());
  }
  } ///:~
  grant {
  // Allow everything for now
  permission java.security.AllPermission;
  };
  
  存入于F:/rmi下
  操作步驟
  F:/rmi>java PerfectTime
  Ready to do time
  F:/rmi>javac *.java
  F:/rmi>rmic PerfectTime
  F:/rmi>start rmiregistry
  F:/rmi>java PerfectTime
  Ready to do time
  另開一DOS窗口
  F:/rmi>java -Djava.security.policy=registerit.policy DisplayPerfectTime
  Perfect time = 1011585443953
  Perfect time = 1011585443968
  Perfect time = 1011585444000
  Perfect time = 1011585444000
  Perfect time = 1011585444015
  Perfect time = 1011585444031
  Perfect time = 1011585444031
  Perfect time = 1011585444046
  Perfect time = 1011585444062
  Perfect time = 1011585444062
  注重:假如在rmic PerfectTime時(shí)報(bào)找不到PerfectTime類,請(qǐng)?jiān)诃h(huán)境變量中的ClassPath中加入:F:/rmi

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 泸定县| 普宁市| 福清市| 大港区| 紫金县| 盱眙县| 南华县| 鹤峰县| 康保县| 建湖县| 三穗县| 深泽县| 大方县| 英吉沙县| 大洼县| 新巴尔虎右旗| 罗源县| 慈溪市| 黄骅市| 佛教| 合水县| 宝兴县| 留坝县| 白山市| 砚山县| 平潭县| 平安县| 鄂尔多斯市| 浦江县| 汽车| 宜兰市| 石柱| 綦江县| 安西县| 台江县| 山西省| 滨州市| 阜康市| 峨边| 安平县| 铁力市|