主要步骤
1. 创建远程接口及声明远程方法(RmiMonitorService.java)
2. 实现远程接口及远程方法(继承UnicastRemoteObject)(RmiMonitorServiceImpl.java)
3. 启动RMI注册服务,并注册远程对象(RmiServer.java)
4. 客户端查找远程对象,并调用远程方法(MonitorClient.java)
另外两个辅助类:
1.WarnService.java
2.WarnServiceImpl .java
出现的问题:
1、java.rmi.server.ExportException: remote object implements illegal remote interface; nested exception is:
这是由于接口和方面没有抛出异常导致,在每个方法和结构都加上throws RemoteException 就解决了
转载:http://www.javaeye.com/topic/744239
爱美丽女性网 美容 彩妆 发型 护肤 服饰 情感|分享生活美学,专注女性时尚