how to find machine name

hi,

i would like to write a java program to find out the machine name.

for example, if i run that java program on my machine so it should return my machine name.

if someone already written that kind of code, please send it to me

thanks for your help and have a great weekend

[305 byte] By [seaworld_07a] at [2007-11-27 6:53:53]
# 1
Look at java.net.InetAddress.InetAddress.getLocalHost() will give you the machine name and ipaddress.
Jyothi_Madhavabhatlaa at 2007-7-12 18:28:44 > top of Java-index,Java Essentials,New To Java...
# 2
[url= http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getProperties()]System getProperties()[/url] will return the user accountbut not the computer name. I may be wrong but I dont believe the previous post is correct.
TuringPesta at 2007-7-12 18:28:44 > top of Java-index,Java Essentials,New To Java...
# 3
how do you post the duke picture?
pooperscoopera at 2007-7-12 18:28:44 > top of Java-index,Java Essentials,New To Java...
# 4
Why? Do you want to be a troll like myorak?
TuringPesta at 2007-7-12 18:28:44 > top of Java-index,Java Essentials,New To Java...
# 5
> Why? Do you want to be a troll like myorak?Troll?I wasn't here, what happened with that thread (besides it getting deleted)?
CaptainMorgan08a at 2007-7-12 18:28:44 > top of Java-index,Java Essentials,New To Java...
# 6
I was half joking with the troll comment, lol, but yea that thread just continued on and on with his flood posting.at least he always keeps it local to one thread.
TuringPesta at 2007-7-12 18:28:44 > top of Java-index,Java Essentials,New To Java...
# 7

> > Why? Do you want to be a troll like myorak?

>

> Troll?

>

> I wasn't here, what happened with that thread

> (besides it getting deleted)?

He combined the image trickery with the posting voodoo for evil. Because the image thing is just a url right.... one can use whatever url one wants.

cotton.ma at 2007-7-12 18:28:44 > top of Java-index,Java Essentials,New To Java...
# 8
> He combined the image trickery with the posting> voodoo for evil. Because the image thing is just a> url right.... one can use whatever url one wants.I saw that part, but I had to leave right afterwards...
CaptainMorgan08a at 2007-7-12 18:28:44 > top of Java-index,Java Essentials,New To Java...
# 9

> > He combined the image trickery with the posting

> > voodoo for evil. Because the image thing is just a

> > url right.... one can use whatever url one wants.

>

> I saw that part, but I had to leave right

> afterwards...

Well he posted several and it went bananas. It was well over 100 replies last I saw.

cotton.ma at 2007-7-12 18:28:44 > top of Java-index,Java Essentials,New To Java...
# 10

/**

* @(#)AddressCheck.java

*

*

* @author

* @version 1.00 2007/6/9

*/

import java.net.*;

public class AddressCheck {

public static void main(String[] args) {

String address = "";

try {

address=InetAddress.getLocalHost().toString();

} catch (Exception e) {

e.printStackTrace();

}

System.out.println(address);

}

}

running on my machine will print

saloo/192.168.1.105

fastmikea at 2007-7-12 18:28:44 > top of Java-index,Java Essentials,New To Java...
# 11
but how could we just get system name not ip with it?
@tifa at 2007-7-12 18:28:44 > top of Java-index,Java Essentials,New To Java...
# 12
> but how could we just get system name not ip with it?By reading the API docs and finding there is a getHostName() method.String address = InetAddress.getLocalHost().getHostName();
prometheuzza at 2007-7-12 18:28:44 > top of Java-index,Java Essentials,New To Java...