I try,but failed.Use c,it work

解决方案 »

  1.   

    Ping的实现要用到ICMP,它并不是什么高层协议,而是IP的一部分。如果要发送ICMP消息,必须能够直接操作IP数据报头。标准Java API没有提供这一层次上的直接支持,最好用C/C++作为本地代码实现。
      

  2.   

    impossible! icmp package relative to the system.No matter what jdk,it never support that.Use InetAddress class ,test the 25 port or 23 port or else,to emulate the ping.In my project,I use fping command to instead of it.
      

  3.   

    你自己编个ping的类就行了,只需要用到InetAddress这个类,很简单的。
      

  4.   

    严重同样holly1900();现在java还没有很好的处理方法。
    现有的几种途径:
    1。调用本地ping方法,分析返回字符串。一个问题是,jdk1.3在windows上会缺省弹出console窗口,1.4就好了。
    2。对应不同平台用C写本地调用方法,通过jni调用。
    3。由InetAddress访问23,或25端口,问题是如果机器没有开这些端口,就会访问不到。
      

  5.   

    如果只是要调用ping,那用runtime.exec直接调就可以了
    否则就自己用c来写,然后jni调用吧