GeeCON Prague 2014*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Getting the hostname from command line - Is it a violation from Instructions. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Getting the hostname from command line - Is it a violation from Instructions." Watch "Getting the hostname from command line - Is it a violation from Instructions." New topic
Author

Getting the hostname from command line - Is it a violation from Instructions.

Jayakumar Duraisamy
Ranch Hand

Joined: May 07, 2001
Posts: 31
Hello,
I have written my README file and still in the 90% Syndrome. A sudden question popped out in my mind. Right now i am passing the hostname, port no, to the CLIENT through java command line by using -D flag. Something like as follows.
java -Drmi.server.hostname=localhost -Dportno=1099 -Ddatafile=db.db MyClient.
I am sure about all except the hostname. This doubt has rose after reading a recent postings by Tina et all.
Any help is highly appreciated.
Thanks
Jay
Akanimo Udoh
Ranch Hand

Joined: Jun 11, 2001
Posts: 48
Jay,
I think you may be misusing the command line in the example you gave:
"java -Drmi.server.hostname=localhost -Dportno=1099 -Ddatafile=db.db MyClient"
If you see the help for the java command line options it describes the '-D' option as
-D<name>=<value> set a system property
and you can get a list of these 'system' properties if you look at System.getProperties() in the online help.
Its not really the proper way to pass 'application' parameters like the RMI server address, port, filename etc. These type of parameters should really go to the application's main function for handling.
See Tina's thread for some more comments on the rmi.server.hostname system parameter.
Akanimo.
Jayakumar Duraisamy
Ranch Hand

Joined: May 07, 2001
Posts: 31
Hi,
I appreciate your reply.
As far as i understand, it is nothing wrong to use -D to set port. Because as far as our application is considered it is a system property.
I also understood later, that specifying the hostname via commandline is not violating the instructions.
Thanks
Jay
 
GeeCON Prague 2014
 
subject: Getting the hostname from command line - Is it a violation from Instructions.