public interface MyRemote extends Remote { public int myFunc(int i) throws RemoteException; }
public class MyRemoteImpl implements MyRemote { public int myFunc(int i) { return i; } }
MyRemoteImpl m = new MyRemoteImpl(); String url = "rmi://xxx.xxx.xx.xx/myExample"; Naming.bind(url, m); //远程对象m被绑定并存储到url中
String url = "rmi://xxx.xxx.xx.xx/myExample"; MyRemoteImpl my = (MyRemoteImpl)Naming.lookup(url);通过Naming.lookup( )方法,获取得到MyRemoteImpl的对象引用,即”获取远程对象的引用“