I am trying to ping www.google.com in my office network but it is not pinging. Code which i am using is as follows:
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class demo1 {
public static void main(String[] args) throws UnknownHostException, IOException {
try {
String address = InetAddress.getByName("www.google.com").getHostAddress();
InetAddress inet = InetAddress.getByName(address);
System.out.println("Sending Ping Request to " + address);
if(inet.isReachable(50000)){
System.out.println("Host is reachable");
}
else{
System.out.println("Host is not reachable");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
I dont know what is the issue. It cant ping to www.facebook.com or www.youtube.com. I get "Host is not reachable" but it can ping to my office internal systems. In the browser all these external systems like google.com opens but Why it can't ping, I don't know. So, can anyone please help me with this?