This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hello all. Can anyone tell me how I would get the name of a machine that java is executing on? I cannot seem to figure out which property holds that info. Raul
Fred Hosch
Author
Greenhorn
Joined: Apr 16, 2001
Posts: 23
posted
0
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>
Raul Quintero
Greenhorn
Joined: Feb 18, 2000
Posts: 7
posted
0
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
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
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
Frank Carver
Sheriff
Joined: Jan 07, 1999
Posts: 6913
posted
0
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
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.