This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Invoking Java Program Before JVM Stops
 
Similar Threads
ANT: calling a target from another build file
Runtime.addShutdownHook method ???
Datasource configuration for Cloudscape
Assignment submission file structure verification / ant build.xml
regular expressions