File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Distributed Java and the fly likes RMI Naming and registry Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI Naming and registry" Watch "RMI Naming and registry" New topic

RMI Naming and registry

Ranadhir Nag
Ranch Hand

Joined: Mar 09, 2006
Posts: 138
I am new to RMI;What is the difference between the Registry and naming services for lookup?
I see examples that do:

Registry registry = LocateRegistry.getRegistry(RemoteInterface.REGISTRY_PORT);
RemoteInterface remoteReference =
(RemoteInterface) UnicastRemoteObject.exportObject(new Server());
registry.rebind(RemoteInterface.REGISTRY_NAME, remoteReference);

as well as examples that do :
AccountImpl acct = new AccountImpl("JimF");

// Register it with the local naming registry
Naming.rebind("JimF", acct);

So what's the difference in binding to registry and naming service.I understand that both of them refer to the Registry in any case.
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

cross post:

Ed's latest article: A Java Reactive Generator
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

In the first case, this means that your server class programatically starts a new instance of the naming service/registry on the ip,port,etc. specified, and binds itself to it. When your server class shuts down, so does the naming service.

In the second case, your server class binds itself to the naming service/registry already running on the specified ip,port,etc. This registry could have been started from another program or the command line - but it is independent of your server class and doesn't shutdown if your server does.

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: RMI Naming and registry
jQuery in Action, 3rd edition