When a fatal error occurs, the Java VM can optionally
execute a user-supplied script or command. The script or command is
specified using the -XX:OnError:<string> command-line option, where <string> is a single command or a list of commands each separated
by a semicolon. Within <string> all occurrences of “%p” are replaced with
the current process id (pid), and all occurrences of “%%”
are replaced by a single “%”.
The following example shows how the fatal error
report can be mailed to a support alias when a fatal error is encountered:
$ java -XX:OnError=”cat hs_err_pid%p.log|mail support@acme.com” MyApplication |
The following example shows how to execute gdb when an unexpected error is encountered. After gdb is started, it attaches to the Java VM process:
$ java -XX:OnError=”gdb - %p” MyApplication |