How can I catch when somebody kills my application (java, but it is not important) by taskmanager or by taskkill console command?
I understand that I cannot catch t
There is no (standard) way to figure out when your application is killed by the task manager with Java.
The usual approach is to have a second application which starts the main application as a child process (use ProcessBuilder
). The wrapper will notice when the child dies. For all the usual termination reasons, set an exit code via System.exit()
in your main app. In your wrapper, check the exit code. If it isn't one you explicitly set, then someone killed the app or it crashed because of a VM bug.
To distinguish those two, check the output of the child app and look for VM crash dumps in the current directory (whatever that may be for your app; usually it's the directory in which your app was installed).