I register a RMI Object using these codes on the Server side:
IHello stub = (IHello)UnicastRemoteObject.exportObject(obj, 20200);
Registry registry = LocateRegistry.createRegistry(20222);
registry.bind("A Say Hello Remote Object", stub);
When I get this remote Object from client:
IHello stub = (IHello)Naming.lookup("rmi://localhost:20222/A Say Hello Remote Object");
This will throws an Exception:
java.net.MalformedURLException: invalid URL STring rmi://localhost:20222/A Say Hello Remote Object.
On the client side, I can use regitry.lookup("A Say Hello Remote Object")
to find this object. But why the Naming.lookup()
method can't work?