Hi, According to the instruction (Hotel Room Booking), we should run a specified class and accept the parameter from the user(server|client|standalone), but how to keep the RMI factory service running always? and what's the right approach to stop the service? Regards! Frank.
posted 15 years ago
Let me make it more clear: the below is from the Sun instruction: When you submit your assignment, each part (client and server) must be executable using a command of this exact form: java -jar <path_and_filename> [<mode>] Your programs must not require use of command line arguments other than the single mode flag, which must be supported. Your programs must not require use of command line property specifications. All configuration must be done via a GUI, and must be persistent between runs of the program. Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory. The mode flag must be either "server", indicating the server program must run, "alone", indicating standalone mode, or left out entirely, in which case the network client and gui must run. Please comment it. Thanks! Frank
I've been using (as others have suggested): java.rmi.registry.LocateRegistry.createRegistry(1099); Which starts the registry programmatically. It will shut down automatically when the server application exits. My question, though, is what to do if the registry is already running? This call will throw an exception that the port is already in use. I haven't got the whole classpath thing figured out yet. If the registry is already running, I assumed I could just go ahead and bind my remote object, but I'm having trouble with the registry finding the stubs if it was started from a command line in a different working directory. Anyone know more about this?