Java: Global Exception Handler

前端 未结 6 1404
孤独总比滥情好
孤独总比滥情好 2020-11-27 03:06

Is there a way to make a global exception-handler in Java. I want to use like this:

\"When an exception is thrown somewhere in the WHOLE program, exit.\"
         


        
6条回答
  •  不知归路
    2020-11-27 03:58

    DefaultUncaughtExceptionHandler is the correct answer. It was revealed to me by Jeff Storey at this location, a few days ago. As u suspected, the "manually" caught exceptions will never be caught by this handler. However i got the following warning :

    **- To be compliant to J2EE, a webapp should not use any thread.**

    when i have checked my project against good-practice and recommended java coding style with PMD plug-in for Eclipse IDE.

提交回复
热议问题