I need to ping a remote site to see if it is available for service.

When I ping it from a command shell (e.g., "ping www.yahoo.com"), it shows the site is accessible.

So I run the following Java.

Java Code:
import java.net.InetAddress;

public class Test 
  static String yahoo = "www.yahoo.com";

  public static void main(String[] args) throws Exception {
    InetAddress address = InetAddress.getByName(yahoo);

    boolean reachable = address.isReachable(10000);

    System.out.println("Is host reachable? " + reachable);
After the system times out, it outputs reachable as false.

If I point getByName at my router, it works fine. Clearly ping is able to look beyond the LAN, but the Java code cannot.

My question is why not? Does it have to do with the router letting certain sockets through (e.g., the one associated with ping) but not others (e.g., the one used by InetAddress)?