Generally you can send a "ping" command to the server.
If you want to check if the server listens on a specific port, you need to initiates a socket connection at the specified port. Google "Java...