Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Default how to get computer ip by hostname

    Hello, there is device in my lan called 'dupa'
    When I do 'ping dupa' I receive

    C:\Users\Maks>ping dupa

    Badanie dupa [192.168.2.5] z 32 bajtami danych:
    Odpowiedź z 192.168.2.5: bajtów=32 czas=1ms TTL=128
    Odpowiedź z 192.168.2.5: bajtów=32 czas=1ms TTL=128
    Odpowiedź z 192.168.2.5: bajtów=32 czas=1ms TTL=128
    Odpowiedź z 192.168.2.5: bajtów=32 czas=1ms TTL=128
    ...

    So, I received ip number. The question is, how can I do this using java code ??

  2. #2
    Join Date
    Feb 2011
    Location
    Ahmedabad
    Posts
    36
    Rep Power
    0

    Default Re: how to get computer ip by hostname

    Hi vic_Rattlehead

    You can try following


    InetAddress.getByName(hostname).getHostAddress()
    Hemant Metalia
    cool

  3. #3
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Default Re: how to get computer ip by hostname

    It doesn't work :/ tried it
    throws UnknownHostException
    It works on addresses like Google
    but getByName("dupa") don't
    pinging both google and dupa work

  4. #4
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Default Re: how to get computer ip by hostname

    getByName doesn't work
    it works on www.google.com or somethink but not on 'dupa'
    ping works on both google and dupa

    It works on c# using
    IPHostEntry host = Dns.GetHostEntry("dupa");
    But need to get it work on java

Similar Threads

  1. Replies: 3
    Last Post: 07-25-2011, 04:19 PM
  2. Help with Computer Ai
    By SilentCoder in forum Java Gaming
    Replies: 14
    Last Post: 06-10-2011, 02:37 AM
  3. IPAddress or HostName
    By abhijeet_152 in forum Networking
    Replies: 1
    Last Post: 11-27-2008, 07: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, 02:43 PM
  5. IP to HostName
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-11-2007, 09: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
  •