In answer to your original question, if I understand correctly, what you want to do is start the RMI registry using a user-defined port number?
If this is the case I would recommend displaying a GUI to the user (created and displayed by an object i.e. ApplicationRunner.java with a main method that is not the server and does not require RMI to be running) and then ask for the appropriate information (url, port), and only then do you need to start the registry and instantiate your server object using the GUI object.
SCJP 1.4,<br />SCJD (URLyBird 1.2.1, JDK 5.0)
Joined: Dec 31, 2004
The answer to your last question is fairly evident. If you create the RMIRegistry and bind your objects and you simply let your program finish then your server dies.
You have to make sure your application will not die until you want so. For instance (this is just for an example), put System.read() at the end of your server initilization code, so that your server dies until you press enter.
Evidently you will have to provide some way to the end user to shut down the server when he wants.
This will require a shutdown strategy in order that any pendant transaction is completed before the server dies, and no further transactions should be accepted while the server is shutting down.