API to get computer name

M

Matt

i want to get computer name in Java program. I tried to use
System.getProperty(), but seems like there is no appropriate key.

please advise. thanks!!
 
R

Roedy Green

i want to get computer name in Java program. I tried to use
System.getProperty(), but seems like there is no appropriate key.

MS even took the MAC address out of its unique key generator,
considering that information a security risk.

I have http://mindprod.com/products.html#PENTIUM
which gets the pentium III+ serial number. Does not work for AMD
chips which have no serial number.

You could go for the MAC address. MS made it difficult to get at.
 
R

Real Gagnon

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.
 
S

Steve Yates

i want to get computer name in Java program. I tried to use
System.getProperty(), but seems like there is no appropriate key.

please advise. thanks!!

Try java.net.InetAddress.getLocalHost().getHostName()
 
S

Spalinger Hanspeter

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top