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.

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.");
}

}

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.