How can I catch AWT thread exceptions in Java?

后端 未结 4 1054
时光取名叫无心
时光取名叫无心 2020-12-06 05:03

We\'d like a trace in our application logs of these exceptions - by default Java just outputs them to the console.

4条回答
  •  情话喂你
    2020-12-06 05:18

    There are two ways:

    1. /* Install a Thread.UncaughtExceptionHandler on the EDT */
    2. Set a system property: System.setProperty("sun.awt.exception.handler",MyExceptionHandler.class.getName());

    I don't know if the latter works on non-SUN jvms.

    --

    Indeed, the first is not correct, it's only a mechanism for detecting a crashed thread.

提交回复
热议问题