For RMI on server-side, do we need to start rmiregistry
program, or just call LocateRegistry.createRegistry
?
If both are possible, what are the advantages and disadvantages?
They're the same thing... rmiregistry
is a separate program, which you can run from a command line or a script, while LocateRegistry.createRegistry
does the same thing programatically.
In my experience, for "real" servers you will want to use rmiregistry
so that you know it's always running regardless of whether or not the client application is started. createRegistry
is very useful for testing, as you can start and stop the registry from your test as necessary.