Link to home
Start Free TrialLog in
Avatar of richardsimnett
richardsimnett

asked on

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

Hello,
This is basically an extension of the quesiton asked in https://www.experts-exchange.com/questions/21393571/How-do-I-capture-a-program-halt-stop-event.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
Avatar of Mick Barry
Mick Barry
Flag of Australia image

What are you using to run your app as a service?
What are you using to run it as a service?
The code that is handling running it as a service should be notifying when to stop the service.
Avatar of richardsimnett
richardsimnett

ASKER

I am using the app referred to me in this question:

https://www.experts-exchange.com/questions/21343238/how-do-I-make-a-java-app-load-at-windows-startup.html

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

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

Thanks,
Rick
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).
ASKER CERTIFIED SOLUTION
Avatar of aozarov
aozarov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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