Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

LocateRegistry.createRegistry vs rmiregistry  RSS feed

 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I know when starting an RMI registry I can use either LocateRegistry.createRegistry(port) or running the rmiregistry.exe program. I tried to export objects using UnicastRemoteObject.exportObject(obj,port) and used the same port number as the RMI registry port. If I started the RMI registry using LocateRegistry.createRegistry, it works fine. But if I started it using rmiregistry.exe, I get a port already in use exception. I understand why I get the port in use exception, but why don't I get it when I've started the reigstry using LocateRegistry.createRegistry? Thanks.

Jeff
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RMI registry is just another RMI server object and RMI has a concept of sharing the same server socket for multiple server objects, as specified here.

In case you start the registry from outside the JVM, the JVM can not share the socket as it is a different process but if you start it using LocateRegistry, then RMI can share the port between two server objects.

P.S.: I do not have a document that talks about this but this is according to my understanding of RMI.
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Makes sense. The safe way is probably just to use an anonymous service port. Thanks.

Jeff
 
Alberto Ivo
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys,

which one is a better programing practice? LocateRegistry.createRegistry or rmiregistry.exe? And why?
If depends, which case is better each one?

thanks in advance.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!