How can I catch moment when someone kill java.exe process?
<p>console java application. Someone kill java.exe process by Task Manager. How can I write to logs some information at this moment before application is terminated? </p>

<pre><code>Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
    public void uncaughtException(Thread t, Throwable e) { ..... }
});
</code></pre>

<p>OR </p>

<pre><code>Runtime.getRuntime().addShutdownHook(new Thread() {
    public void run() { ..... }
});
</code></pre>

<p>don't execute in such situation</p>
