Results 1 to 2 of 2
  1. #1
    JavaEmpires is offline Member
    Join Date
    Dec 2007
    Rep Power

    Default Java failed to reach to a PC in local LAN

    Hi all,
    I tried to execute the following code
    Java Code:
                NetworkInterface ni = NetworkInterface.getByName("eth0");
                System.out.println("\nGetting Host Name ....");
                InetAddress[] addr = InetAddress.getAllByName("");
                for(int i=0;i<addr.length;i++){
                  System.out.println("\nHost Name = "+addr[i].getHostName());
                  System.out.println("\nIs Reachable??  = "+addr[i].isReachable(10));
            catch(Exception e){
                System.out.println("\nError :"+e);
    and the output I got was :
    Java Code:
    Getting Host Name ....
    Host Name =
    Is Reachable??   = false
    But when i PING to it replies back i.e it is reachable from my computer.
    What could be the problem in above code?

    Thanx in advance.

  2. #2
    undertow's Avatar
    undertow is offline Member
    Join Date
    Jan 2008
    Colorado USA
    Rep Power


    javadoc mentions "A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host."

    maybe the JVM is unable to get permission to do an ICMP echo, so it tries a TCP connect on port 7. If you are using windows i would have a look at firewall settings. The ping program might have intrinsic privilege elevation for that kind of thing.

    or maybe the instantiation of the NetworkInterface(doesnt look like you are using it at all) object could be blocking the request.
    Last edited by undertow; 01-24-2008 at 07:32 PM.

Similar Threads

  1. Replies: 3
    Last Post: 05-22-2011, 03:16 PM
  2. Replies: 1
    Last Post: 08-13-2007, 03:46 AM
  3. Loading of JSP file failed
    By Heather in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 08-06-2007, 01:15 AM
  4. Replies: 3
    Last Post: 08-01-2007, 04:20 PM
  5. Compile failed, messages should have been provided
    By leonard in forum New To Java
    Replies: 2
    Last Post: 07-30-2007, 05:36 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