This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 19649
    
  18

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?
 
Similar Threads
Windows Service for Java
Background process to monitor network interfaces
auto starting java program
Tomcat not running
Checking for a Windows Service from Java