Hostname?

How can I get the hostname for the client?
[49 byte] By [Dennis_Madsena] at [2007-10-3 4:56:31]
# 1
What sort of program is this? A webpage? A Socket application you made?
cotton.ma at 2007-7-14 23:01:46 > top of Java-index,Java Essentials,Java Programming...
# 2
NetBean calls it a Java Application. :)
Dennis_Madsena at 2007-7-14 23:01:46 > top of Java-index,Java Essentials,Java Programming...
# 3
> NetBean calls it a Java Application. :)So you want the hostname of the machine the program is running on?
cotton.ma at 2007-7-14 23:01:46 > top of Java-index,Java Essentials,Java Programming...
# 4
Maybe you want?InetAddress.getLocalHost().getCanonicalHostName()
jfbrierea at 2007-7-14 23:01:46 > top of Java-index,Java Essentials,Java Programming...
# 5
> NetBean calls it a Java Application. :)InetAddress.getLocalHost().getHostName();Kaj
kajbja at 2007-7-14 23:01:46 > top of Java-index,Java Essentials,Java Programming...
# 6
try {InetAddress addr = InetAddress.getLocalHost();// Get IP Addressbyte[] ipAddr = addr.getAddress();// Get hostnameString hostname = addr.getHostName();} catch (UnknownHostException e) {}
Jayesh_Java_J2EEa at 2007-7-14 23:01:46 > top of Java-index,Java Essentials,Java Programming...
# 7
Thanks!
Dennis_Madsena at 2007-7-14 23:01:46 > top of Java-index,Java Essentials,Java Programming...