This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
there's probably an easier way, but take a look at getLocalHost java.net.InetAddress. you can then use getHostName.
Fred Hosch<br />Author of:<br /><a href="http://www.amazon.com/exec/obidos/ASIN/0471354899/ref=ase_electricporkchop/107-7882751-0234939" target="_blank" rel="nofollow">An Introduction to Software Construction with Java</a>
Joined: Feb 18, 2000
Thanks for the suggestion. However, this is going to be an internal running program, so I'm not sure if I will be able to use that route. Any other suggestions? Raul
So what exactly do you mean by "name"? The IP address of the machine? The Mac address of the machine? The brand of machine? The operating system that is running on the machine? Just knowing that I call my machine bimbo and that it is an IBM is not useful information. If you look in System.getProperties() there is a list of the things that are available (and meaningful) that are java related.
"JavaRanch, where the deer and the Certified play" - David O'Meara
I'm a little puzzled - what do you mean by "an internal running program"? The method outlined above is the usual way of getting the machine name. I have a hard time envisioning a situation where the concept of a "machine name" makes sense but this call is not available.
Hey guys, sorry if I'm so unclear. Basically, I need to get the name of the server that this program will be running on. In a windows example, if you go into network neighborhood and you see the list of machine names, I need to get that name for that server that's running the app. So if the server is named Bimbo on the network, then I need my file to have Bimbo in there. This neccesarilly isn't an Internet, or networked application, and the machine running it might not have http in it's protocols list, so I'm unclear if I can use the getHostName method. If I can, then I stand corrected. I also went through the list of properties that java sends back and none had what I need. I don't care about OS name, and user dir and such. If this doesn't make sense as to why anyone would want this info, is is used to create log files, and that's what the user wants. Thanks again, and I hope I didn't confuse you guys any further. Raul