This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "NX: Please Help! - Naming.rebind and Port" Watch "NX: Please Help! - Naming.rebind and Port" New topic
Author

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:
java.rmi.registry.LocateRegistry.createRegistry(XXXX);
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: 10820
    
  25

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: NX: Please Help! - Naming.rebind and Port
 
Similar Threads
RMIRegistry
RMI Registry help
rmiregistry programmatically
(B&S) Cant start RMI server on any other port except 1099
RMI Question, Please HELP