File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Checking for a Windows Service from Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Checking for a Windows Service from Java" Watch "Checking for a Windows Service from Java" New topic
Author

Checking for a Windows Service from Java

Barry Brashear
Ranch Hand

Joined: Jun 05, 2001
Posts: 303
Is there a way from Java to determine if a particular windows service
is started?

Thanks.
Horatio Westock
Ranch Hand

Joined: Feb 23, 2005
Posts: 221
I really don't know what the proper way to do this is, but seeing as it's windows only, you could run the command "net start" and read the output, looking for the service you are interested in.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I agree with Horatio. That sounds like a good way to do it.

If you're not familiar with how to start a process outside the JVM, the call is Runtime.getRuntime().exec("net start");

I'd read the following article, though, before coding this, because there are lots of pitfalls in running processes outside the JVM.

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html


Merrill
Consultant, Sima Solutions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Checking for a Windows Service from Java
 
Similar Threads
How to run Java Program as windows service?
how can we write memory resident program
tomcat did not get started from eclipse
Listening for connections
How to call oracle reports from JAVA web application