Getting current machine name

Discussion in 'Java' started by Karen Jones, Nov 23, 2005.

  1. Karen Jones

    Karen Jones Guest

    How do I get the name of the current machine in Java? I thought it would be
    a system property but I can't find it.

    Thanks,

    Karen J.
     
    Karen Jones, Nov 23, 2005
    #1
    1. Advertising

  2. Karen Jones

    Guest

    Karen Jones wrote:
    > How do I get the name of the current machine in Java? I thought it would be
    > a system property but I can't find it.
    >
    > Thanks,
    >
    > Karen J.


    There may be an easier way, but this worked for me:

    InetAddress addr = InetAddress.getLocalHost();
    System.out.println("hostname = " + addr.getHostName());
     
    , Nov 23, 2005
    #2
    1. Advertising

  3. Karen Jones

    Joan Guest

    In 1.5 you can get env variables.
    For windows xp you can look up COMPUTERNAME.

    "Karen Jones" <> wrote in message
    news:438450f8$0$12463$...
    > How do I get the name of the current machine in Java? I
    > thought it would be
    > a system property but I can't find it.
    >
    > Thanks,
    >
    > Karen J.
    >
    >
     
    Joan, Nov 24, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nalbayo
    Replies:
    2
    Views:
    5,519
    Bruce Barker
    Nov 11, 2005
  2. Anil G
    Replies:
    4
    Views:
    22,916
    v_parthi
    Jan 31, 2008
  3. Montand
    Replies:
    1
    Views:
    547
    Alexey Smirnov
    Feb 20, 2008
  4. Jason

    Using DNS name verses Machine Name causes 403 error

    Jason, Sep 13, 2006, in forum: ASP .Net Web Services
    Replies:
    5
    Views:
    294
    Steven Cheng[MSFT]
    Sep 18, 2006
  5. Matthew Heidemann
    Replies:
    14
    Views:
    252
    eT Ma
    Mar 22, 2011
Loading...

Share This Page