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
You can do simply by java application too, by using two apps. This is how it is done in many pure java produciton systems
Your other program(maybe call it janitor app) will keep do a lock() call on it and keep on waiting.
When the lock call returns you can be sure that your main app is terminated. Now you can determine.
As far as "Why applicaiton is killed " question, technically you cannot find out(maybe 1 or 2 scenarios , but not all scenarios), AFAIK.