0

hey guys,
I was wondering if there is anyway that my java app could retrieve the computer name.

IE
My computer could be named "PhiberOptik-desktop" I want to retreive "PhiberOptik-desktop" !

Thanks PO.

1
Contributor
1
Reply
2
Views
8 Years
Discussion Span
Last Post by PhiberOptik
0

Nevermind Figured it out!

import java.net.*;

class myName {

public static void main (String args[]) {

try {
InetAddress address = InetAddress.getLocalHost();
System.out.println("Hello. My name is " + address.getHostName());
}
catch (UnknownHostException e) {
System.out.println("I'm sorry. I don't know my own name.");
}

}

}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.