Here you can find the source of ping(String ip)
public static boolean ping(String ip)
//package com.java2s; import java.io.IOException; public class Main { public static boolean ping(String ip) { try {// ww w . ja va 2 s. c o m Process p = Runtime.getRuntime().exec("ping " + ip + " 1"); return (p.waitFor() == 0); } catch (IOException e) { return false; } catch (InterruptedException e) { return false; } } }