wood burning stoves 2.0*
The moose likes Java in General and the fly likes Invoking Java Program Before JVM Stops Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Invoking Java Program Before JVM Stops" Watch "Invoking Java Program Before JVM Stops" New topic
Author

Invoking Java Program Before JVM Stops

Steven Wong
Ranch Hand

Joined: Mar 07, 2002
Posts: 295
Hi,
If I have a Java process running and I terminate the JVM through the Unix console (kill -9 <<process id>> , can I still manage to trigger
some process before the Java application stops?
I would like to trigger the process through Java programmatically.


best regards,<br />Steven<br />SCJP, SCEA
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Take a look at Runtime.addShutdownHook(Thread hook). Be sure to read thru the caveats listed in tha API docs. The hook must do its work quickly and be thread-safe and avoid deadlocks.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Steven Wong
Ranch Hand

Joined: Mar 07, 2002
Posts: 295
Thanks, Michael
 
Consider Paul's rocket mass heater.
 
subject: Invoking Java Program Before JVM Stops
 
Similar Threads
regular expressions
Datasource configuration for Cloudscape
ANT: calling a target from another build file
Assignment submission file structure verification / ant build.xml
Runtime.addShutdownHook method ???