aspose file tools*
The moose likes Java in General and the fly likes How to verify Windows Service is started or not through 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 "How to verify Windows Service is started or not through Java?" Watch "How to verify Windows Service is started or not through Java?" New topic
Author

How to verify Windows Service is started or not through Java?

Kaarthick Ramamoorthy
Greenhorn

Joined: Sep 01, 2006
Posts: 23
Hi all,

Could any one help me to verify whether Windows service is already started or not using Java?

Any API available?

Thanks in advance.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

You can do this in two ways:
1) use JNI. You will need several native Windows calls for this: OpenSCManager, OpenService and QueryServiceStatus for retrieving, and CloseServiceHandle for cleaning up.

2) use the SC command. For instance, to query whether or not my IIS web server is running:

You'll need to run this using ProcessBuilder (or Runtime.exec), and then parse the output.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Kaarthick Ramamoorthy
Greenhorn

Joined: Sep 01, 2006
Posts: 23
I tried this. It works. Thank you Prime.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to verify Windows Service is started or not through Java?