File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Devesh H Rao
Ranch Hand
Posts: 687
Hibernate jQuery Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Devesh H Rao
Ranch Hand
Posts: 687
Hibernate jQuery Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 687
Hibernate jQuery Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic