dshrenik
asked on
Check status of a service
Please let me know how I can check if a particular service is running through java code on both a Windows machine and a Mac.
Thanks!
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
For example, if I want to check if mysql is running, how do I figure that out?
This code is not working:
This code is not working:
try {
int timeout = 2000;
InetAddress[] addresses = InetAddress.getAllByName("mysql");
for (InetAddress address : addresses) {
if (address.isReachable(timeout))
System.out.printf("%s is reachable%n", address);
else
System.out.printf("%s could not be contacted%n", address);
}
} catch (Exception e) {
System.out.printf("Unknown host: %s%n", "www.java2s.com");
}
To be reasonably sure: connect to the default mysql port. To be 100% sure, you'd have to become a (successful) mysql client
ASKER
I had to use "mysql.net".
Thanks!
Thanks!
:)
ASKER