|
Re: Computer Name using Java
|
Posted: Mar 5, 2002 10:16 AM
|
|
> I would like to find a way in which i can get hold of > the computer name using java.
Hello,
If you intend to get the computer name on a Microsoft operating system, i think that's a bad idea because i think (i'm maybe wrong) that will not work on other operating systems.
You should try to get the computers name using that piece of code (which is portable on others OS) :
import java.net.InetAddress;
// Get machine name
string machine;
InetAddress MyInetAddress = MyInetAddress.getLocalHost();
machine = MyInetAddress.getHostName();
System.out.println("This computer is named : " + machine);
Note that i didn't try that code, it may have some little compilation errors !
Hope this help ! :-)
|
|