Results 1 to 3 of 3
  1. #1
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default Error Getting HostName

    I want to print the local host name, but it always prints null .. how can I get host name ?
    Java Code:
    String hostname = System.getenv("HOSTNAME");
    		System.err.println("Hostname = " + hostname);

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,876
    Rep Power
    5

    Default Re: Error Getting HostName

    So apparently there is no environmental variable HOSTNAME.

    "How can I get host name" -> an excellent question to paste into google, but make it context specific so google "java how can I get hostname". Its so easy to get instant answers to "How do I..." questions.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

Similar Threads

  1. how to get computer ip by hostname
    By vic_Rattlehead in forum Networking
    Replies: 3
    Last Post: 10-07-2011, 02:19 PM
  2. Replies: 3
    Last Post: 07-25-2011, 03:19 PM
  3. IPAddress or HostName
    By abhijeet_152 in forum Networking
    Replies: 1
    Last Post: 11-27-2008, 06:58 PM
  4. Get the IP address&hostname of the host from the LANs
    By linux0kernel in forum Networking
    Replies: 3
    Last Post: 10-16-2008, 01:43 PM
  5. IP to HostName
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-11-2007, 08:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •