Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How do I catch a net stop event in windows and execute a shutdown hook?

Posted on 2005-04-25
7
Medium Priority
?
214 Views
Last Modified: 2010-03-31
Hello,
This is basically an extension of the quesiton asked in http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21393571.html. Basically I need to capture a stop event, however, the java app runs as a service under windows... I need to know how to catch the event, and perform a task before the actual java app stops. Can someone tell me how to do this properly?

Worth 500 points.

Thanks,
Rick
0
Comment
Question by:richardsimnett
7 Comments
 
LVL 92

Expert Comment

by:objects
ID: 13863204
What are you using to run your app as a service?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13863210
What are you using to run it as a service?
0
 
LVL 92

Expert Comment

by:objects
ID: 13863216
The code that is handling running it as a service should be notifying when to stop the service.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:richardsimnett
ID: 13863300
I am using the app referred to me in this question:

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21343238.html

http://www.devx.com/Java/Article/21604

Basically, it generates and exe which then registers, and executes the service when called.

Thanks,
Rick
0
 
LVL 92

Expert Comment

by:objects
ID: 13863327
You need to check what hooks that product provides for handling shutdown.
And if it doesn't you'll need to implement them yourself (if you have the C source).
0
 
LVL 15

Accepted Solution

by:
aozarov earned 2000 total points
ID: 13863830
Check if the utility that runs/wrap your application as a service can provide you with callbacks when stop/start the service.
When looking at: http://www.kcmultimedia.com/javaserv/
From the list you provided in your first link it seems that you can get such callback:
"Code that demonstrates passing native SERVICE_STOPPED events from NT's Service Control Manager to a pure java listener class that can be built into your Java application. (No JNI calls are needed in the Java application.) "
0
 

Author Comment

by:richardsimnett
ID: 13937698
Ok well it appears I will have to switch the wrapper I was using for this. I wrote the author of the wrapper with no response.

Thanks for your help,
Rick
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Don’ts and Dos are two important end products of software testing basics that a tester needs to regard. This article attempts to explain the principles of both.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question