wood burning stoves*
The moose likes Beginning Java and the fly likes Handling program termination Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Handling program termination" Watch "Handling program termination" New topic
Author

Handling program termination

John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Hi,

Is there a way i can handle abrupt termination of my java program in code ( like finally available for the try block)?

My program is a JMS Thread and users can either run it locally on their eclipse or as a Windows Service (not yet implemented).

I would like to handle hard stop like Terminate in Eclipse in code / stop service using Windows -> Services admin tool.
I would like to just print a log.error ("Stopping JMS Service abruptly...."); at the end.

Thanks,
John
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Is there any finally block to handle thread termination?
Haiti Meid
Greenhorn

Joined: Jun 08, 2011
Posts: 13

Hi John, you can try this: http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)


Sorry for my English...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Handling program termination
 
Similar Threads
How can i run my java program as service in Window NT
setting tomcat5.5 server in eclipse
Is there a free JMS implementations that doesn't suck?
Command Window Shutting Down....
Converting Java Application into Windows Service ?