i want to get computer name in Java program. I tried to use
System.getProperty(), but seems like there is no appropriate key.
Modern windows installation have the environment variable COMPUTERNAME.
So pass it to your JVM as java -Dcomputername="%COMPUTERNAME%" ...
and the get the value with System.getProperty("computername")
or
use the jdk1.5 which can extract environment variable direclty with
System.getenv("COMPUTERNAME")
Bye.[/QUOTE]
Good Idea, but what is if you don't use windows? The use of the Network
funktions to get the hostname (as mentioned by others) works on every
system using a IP Network, what as far as I know is every (in use)
System on the world. So for portability reason this should be the better
way.