Windows and Unix Services status through java code
posted 4 years ago
The right way for Windows services is to a) use JNI to query the remote services, or b) use the "sc" command with Runtime.exec / ProcessBuilder. For Unix I don't think there's a uniform way, as I don't think there's a uniform way to do this on local machines themselves. Often you can use the service script in combination with "status" (e.g. /etc/init.d/sshd status) but the "status" argument may not be supported. Either way, you'd also need to connect to the machine using SSH if available.