Hi I need to execute the PING
command using Java code and get summary of the ping host. How to do it in Java?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
as viralpatel specified you can use
Runtime.exec()
following is an example of it
output
refer http://www.velocityreviews.com/forums/t146589-ping-class-java.html
Check out this ping library for java I'm making:
http://code.google.com/p/jpingy/
Maybe it can help
InetAddress
class has a method which uses ECMP Echo Request (aka ping) to determine the hosts availability.If the above
reachable
variable is true, then it means that the host has properly answered with ECMP Echo Reply (aka pong) within given time (in millis).Note: Not all implementations have to use ping. The documentation states that:
Therefore the method can be used to check hosts availability, but it can not universally be used to check for ping-based checks.
Below code will work on both Windows and Linux system,