Hi Sharma, If you are starting the rmiregistry from the command line, then show us the command line. If you are starting it programattically then show us the line of code that starts it. Likewise, show us the line of code that registers with the registry, and that does the lookup on the registry. When we see what you are doing, we will be able to make suggestions. Regards, Andrew
I use the following code to start the registry. java.rmi.registry.LocateRegistry.createRegistry(port); surprisingly if I use any other port except 1099 I get an exception. The message says Connection refused to host <my ip address>. [java.net.ConnectException] Thanks for your help already. -sharma
author and jackaroo
Ken, what is the difference between the Naming and Registry classes? I think the original poster had a problem because he was using the Naming class to bind and unbind remote objects. You created a Registry object to do this however, and avoided the same problems. The API really doesn't seem to tell much.
Joined: Nov 27, 2002
Joy, As near as I can tell, the difference is that the port number is embedded as part of a URL when using Naming instead of being used as a method argument to a direct call on the registry. I changed my code to use Naming as shown below. Both techniques work. I really don't see a good reason to prefer the Naming technique over the one I used which seems simpler, more straightforward, and easier to debug. You still have to create the registry using either technique.
kktec SCJP1.4 & SCWCD
Joined: Nov 27, 2002
After thinking about it a little more, I guess a reason to use Naming would be if the registry is created in another process/JVM and our program is adding services to it. There's no need to do that here. kktec SCJP1.4 & SCWCD
Hi Mao, You can, and this is probably what you would have to do for a real project. However if you do this, and the RMI Registry is started in a directory other than where you code is, you will have to define the codebase. The new assignments do not allow you to specify the codebase on the command line, so you would have to programattically set the codebase. Personally I think you will find it much easier to start the RMI Registry from within your program. This also means that the examiner won't have to start the RMI Registry manually. Regards, Andrew