File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: Please Help! - Naming.rebind and Port Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: Please Help! - Naming.rebind and Port" Watch "NX: Please Help! - Naming.rebind and Port" New topic

NX: Please Help! - Naming.rebind and Port

Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234
Using Max's code and info from some other posts I am trying to
start a user specified port (XXXX = any port) using:
and then I make the call:
RecDatabaseImpl aRec = new RecDatabaseImpl();
Naming.rebind("RecMediator", aRec);
My question is how does the Naming.rebind("RecMediator",aRec) recognize
the port XXXX???
By simply calling java.rmi.registry.LocateRegistry.createRegistry(XXXX)?
I dont understand how the two calls automatically tie into eachother becuase
the Registry object returned by LocateRegistry.createRegistry(XXXX) is
never used. Instead the code simply moves on and calls
Naming.rebind("RecMediator", aRec);
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404

Hi Bill
Max's code starts the RMI Registry on the "well known" port: 1099. The rebind is just using that well known port. It would not work if you used any other port.
This would be a good time for you to visit the Naming API - this will explain how you can specify the port number in the name that you use as a parameter to bind(), rebind(), lookup() ....
I suggest you look at that reference first, then come back with any questions after that.
By the way, the LocateRegistry.createRegistry() method returns a reference to the registry that is started, so you could call rebind() on that reference and then you would not need the port number either.
Regards, Andrew

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234
thanks Andrew, I should have done more homework on this.
It is sorta covered in the JavaRanch Style Guide.
subject: NX: Please Help! - Naming.rebind and Port
Similar Threads
rmiregistry programmatically
RMI Registry help
(B&S) Cant start RMI server on any other port except 1099
RMI Question, Please HELP