Check if Glassfish DAS is running programmatically

后端 未结 3 868
南笙
南笙 2021-01-16 06:52

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

Using Java6

3条回答
  •  太阳男子
    2021-01-16 07:27

    You can use socket to check if your connection up or not :

    i use this way this work with me:

    private boolean checkConnection(String host, int port) {
        try {
            Socket socket = new Socket(host, port);
            socket.close();
            return true;
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
    }
    

    If the socket is created then the connection is up, else the connection is down.

提交回复
热议问题