I am trying to write a program that will monitor my routers and servers and notify me when they go down. I am looking for a way to ping the host and read the reply. The InetAddress.isReachable method is the only thing i could find but it uses the echo port which windows has it off by default. i am looking for something generic that i can use on diffrent platforms. Windows, Linux, Cisco OS.

9 Years
Discussion Span
Last Post by darkagn

Take a look at the Runtime class. You can use its exec method to run a ping and the resulting Process has methods to allow you to obtain the I/O/E streams. This allows you to interpret the results of your ping, but note that there are differences in the ping implementation in Windows and Linux (not sure about Cisco OS sorry).

Hope this gives you some direction,


Runtime() has private access in java.lang.Runtime
Runtime r = new Runtime();

why am i getting this error?


As an aside, if you want to limit people to only use one instance of your class in an application, you can do something like this:

public class myClass {

  private static myClass instance = null;

  private myClass()
    // do something when creating the instance

  public static myClass getInstance()
    if( instance == null )
      instance = new myClass();
    return instance;

The Runtime class does something similar in order to limit the number of instances of Runtime objects to one.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.