Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Java in General and the fly likes how i can track an abnormal termination of a java program. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how i can track an abnormal termination of a java program." Watch "how i can track an abnormal termination of a java program." New topic
Author

how i can track an abnormal termination of a java program.

Devesh H Rao
Ranch Hand

Joined: Feb 09, 2002
Posts: 687

please let me know how can i track an abnormal termination of a java program.
i.e. on press of ^C i should be able to catch the termination and display a message.
thanks for any help.
Karel Young
Greenhorn

Joined: Mar 02, 2004
Posts: 10
Does the System throw an Exception when you do that or not?
I think that there is also an onTermination routine that you may be able to call as well


"We have a choice: the Internet or a life"
Devesh H Rao
Ranch Hand

Joined: Feb 09, 2002
Posts: 687

Originally posted by Karel Young:
Does the System throw an Exception when you do that or not?
I think that there is also an onTermination routine that you may be able to call as well

The system dosent throw an exception on exit.

i am trying out
1. Runtime.addShutdownHook
2. System.runFinalizersOnExit ()
but it is not helping much.
Devesh H Rao
Ranch Hand

Joined: Feb 09, 2002
Posts: 687

Originally posted by Devesh H Rao:

2. System.runFinalizersOnExit ()
but it is not helping much.

This worked ...
Stupid me i wasn't overriding run() in the thread i was trying to hook to runtime....
Now it works i got "In Run" on ^c
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: how i can track an abnormal termination of a java program.