943,906 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 1146
  • Java RSS
Dec 29th, 2008
0

Retrieving Computer Name

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 4
Junior Poster
PhiberOptik is offline Offline
164 posts
since May 2008
Dec 29th, 2008
0

Re: Retrieving Computer Name

Nevermind Figured it out!

java Syntax (Toggle Plain Text)
  1. import java.net.*;
  2.  
  3. class myName {
  4.  
  5. public static void main (String args[]) {
  6.  
  7. try {
  8. InetAddress address = InetAddress.getLocalHost();
  9. System.out.println("Hello. My name is " + address.getHostName());
  10. }
  11. catch (UnknownHostException e) {
  12. System.out.println("I'm sorry. I don't know my own name.");
  13. }
  14.  
  15. }
  16.  
  17. }
Reputation Points: 10
Solved Threads: 4
Junior Poster
PhiberOptik is offline Offline
164 posts
since May 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: IEEE format to decimal conversion
Next Thread in Java Forum Timeline: java vs .net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC