mmc18 mmc18 - 1 year ago 95
Java Question

Check if Glassfish DAS is running programmatically

How to check if Glassfish DAS is running programmatically even if it is deployed on local machine or remote machine?

Using Java6

Answer Source

I have found a way to check if DAS is up other than Linux script. With this way it does not matter if both my application and DAS are at same machine or each installed different machine.

public static boolean isUrlReachable(String host) {
  String URLName="http://"+host+":4848";
  boolean isUp = false;
  try {
     HttpURLConnection con = (HttpURLConnection) new URL(URLName).openConnection();
     isUp = (con.getResponseCode() == HttpURLConnection.HTTP_OK);
  catch (Exception e) {
     return isUp;

  return isUp;


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download