How do I get the name of the current machine in Java? I thought it would be
a system property but I can't find it.
Thanks,
Karen J.
hicks@bigmailbox.net - 23 Nov 2005 11:36 GMT
> How do I get the name of the current machine in Java? I thought it would be
> a system property but I can't find it.
>
> Thanks,
>
> Karen J.
There may be an easier way, but this worked for me:
InetAddress addr = InetAddress.getLocalHost();
System.out.println("hostname = " + addr.getHostName());
Joan - 24 Nov 2005 18:25 GMT
In 1.5 you can get env variables.
For windows xp you can look up COMPUTERNAME.
> How do I get the name of the current machine in Java? I
> thought it would be
[quoted text clipped - 3 lines]
>
> Karen J.