You can create a registry at a given port as follows.
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
...
Registry reg;
...
reg = LocateRegistry.getRegistry(port);
That's fine. But how do I change the port number of the Registry
(reg
) when needed, after initializing it for the first time?.
I've tried to recreate, reg = LocateRegistry.getRegistry(port)
, but that gives some exceptions..