title: Defining one global UncaughtExceptionHandler for all threads of my application
body: <p>I want to define one application level <strong>UncaughtExceptionHandler</strong> in my Java application that is called if an uncaught exception is thrown in one thread of my application. 
  I know that is possible define an uncaught exception for a group of thread (<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/ThreadGroup.html" rel="noreferrer">ThreadGroup</a>) and i'm actually using it, but i want to <em>define a global uncaught exception for threads that don't have defined their own uncaught exception handler or that are not associated to a group of threads that have a default exception handler defined</em>.</p>
  
  <p>So for example i wanna reach something like this :</p>
  
  <pre><code>1° LEVEL ---&gt; Call thread own UncaughtExceptionHandler ---&gt; 2° LEVEL Call Thread Group UncaughtExceptionHandler ---&gt; 3° LEVEL Call application(default) UncaughtExceptionHandler 
  </code></pre>
  
  <p>In simple terms i want to override the default UncaughtExceptionHandler and define my own handler instead of print the stack trace on the <code>System.err</code> (that is the default behaviour).</p>
  
  <p>For example in C# .NET i do something similar handling the <strong>unhandled</strong> and <strong>thread exception</strong> event handler in the Main() method of the application :  </p>
  
  <pre><code>AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); 
  Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
  </code></pre>
  
  <p>Can be done even in Java ? </p>
  
  <p><em>How can i override the default UncaughtExceptionHandler in Java ?</em> </p>