I wrote the following code to try a ping
. But as I run it, the following exception gets thrown :
java.net.UnknownHostException: http://localhost:8084/server/index.jsp
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source)
at java.net.InetAddress.getAddressFromNameService(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at Tester.main(Tester.java:10)
import java.net.InetAddress;
class Tester {
public static void main(String args[]) {
try {
InetAddress address = InetAddress.getByName("http://localhost:8084/server/index.jsp");
boolean isReachable = address.isReachable(2000);
if(isReachable)
System.out.println("The address is reachable");
else
System.out.println("The address is not reachable");
} catch(Exception exc) {
exc.printStackTrace();
}
}
}
Why is it so ? The server is running and the page is opening fine in the web-browser.