RMI Server端。这个其实跟RMIIO关系不大。
package com.sinosuperman.rmiio2;
import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
public class RmiioServer2 {
public static void main(String[] args) {
try {
/* Create a Remote object. */
RmiioService2 testRMIIO = new RmiioServiceImpl2();
/* Create a registry object with 1235 port. */
LocateRegistry.createRegistry(2234);
/* Register the Remote object to RMI registry server, and name it as testrmi. */
Naming.bind("rmi://localhost:2234/testrmiio", testRMIIO);
System.out.println("注册远程对象成功");
} catch (RemoteException e) {
System.out.println("远程对象创建异常");
e.printStackTrace();
} catch (MalformedURLException e) {
System.out.println("URL畸形异常");
e.printStackTrace();
} catch (AlreadyBoundException e) {
System.out.println("重复绑定异常");
e.printStackTrace();
}
}
}
原文链接: http://blog.csdn.net/poechant/article/details/7031737