In addition to the-XX:OnError option, the Java VM can also be provided with the option-XX:+ShowMessageBoxOnError . When this option is set and
a fatal error is encountered, the Java VM outputs information about
the fatal error and ask the user if the debugger should be launched.
The output and prompt are sent to the application console (standard
input and standard output). Following is an example:
==============================================================================
Unexpected Error ------------------------------------------------------------------------------
SIGSEGV (0xb) at pc=0x2000000001164db1, pid=10791, tid=1026
Do you want to debug the problem?
To debug, run 'gdb /proc/10791/exe 10791'; then switch to thread 1026
Enter 'yes' to launch gdb automatically (PATH must include gdb)
Otherwise, press RETURN to abort...
============================================================================== |
In this case, a SIGSEGV has occurred and the user is prompted whether to launch the debugger
to attach to the process. If the user enters “y” or
“yes” then gdb is launched.
In the previous example, the output includes
the process id (10791) and also the thread id (1026). If the debugger
is launched then one of the initial steps taken in the debugger should
be to select the thread and obtain its stack trace.
While waiting for a response from the process,
it is possible to use other tools to obtain a crash dump or query
the state of the process.
Generally, -XX:+ShowMessageBoxOnError option is more useful in a development environment where debugger
tools are available. The -XX:OnError option is more suitable for production environments where a fixed
sequence of commands or scripts are executed when a fatal error is
encountered.