This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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);
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