error handling - How to capture crash logs in Java -


i'm working on cross platform application in java works nicely on windows, linux , macos x. i'm trying work out nice way detection (and handling) of 'crashes'. there easy, cross-platform way detect 'crashes' in java , in response?

i guess 'crashes' mean uncaught exceptions. code use jni it'd nice able catch crashes bad jni code, have feeling that's jvm specific.

for simple catch-all handling, can use following static method in thread. javadoc:

static void setdefaultuncaughtexceptionhandler(thread.uncaughtexceptionhandler eh)
          set default handler invoked when thread abruptly terminates due uncaught exception, , no other handler has been defined thread.

this broad way deal errors or unchecked exceptions may not caught anywhere else.

side-note: it's better if code can catch, log and/or recover exceptions closer source of problem. reserve kind of generalized crash handling totally unrecoverable situations (i.e. subclasses of java.lang.error). try avoid possibility of runtimeexception ever going uncaught, since might possible--and preferable--for software survive that.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -