Epa*_*aga 6 java error-handling crash-reports
让(Java)程序在上次运行时识别崩溃的最佳方法是什么,并显示一条消息"看起来这个程序上次崩溃了.请在这里报告此问题:bla@foo.com. ......"
有推荐的方法吗?(坏?)我的想法是:
Java程序崩溃有三个原因:
try-catch在main.main.我常钓Throwable在main.请参阅下面的模板.Thread.setDefaultUncaughtExceptionHandler().new File(...).deleteOnExit().如果有机会,Java会为你清理它.死锁的问题是如何检测到您有死锁.我还没有看到一致的方法.
import org.apache.commons.lang.exception.ExceptionUtils;
public class Demo
{
public static void main (String[] args)
{
try
{
Demo obj = new Demo ();
obj.run (args);
System.out.println ("Done.");
}
catch (Throwable t)
{
ExceptionUtils.printRootCauseStackTrace (t);
}
}
}
Run Code Online (Sandbox Code Playgroud)