The command parameter may contain the special sequence %p, which is replaced by the process identifier of the JVM process.
The -XX:OnError option allows an operator to specify a command or sequence
of commands to execute when the JVM crashes due to an unrecoverable error.
This can be used for example to generate additional data that could help to
diagnose causes of the crash. Alternatively it could be used to alert the operator
to the crash so that corrective action can be taken (e.g. restarting the process).
The command string can be either a single command, or multiple commands
separated by semicolons. If the command string contains one or more instances
of the special sequence %p then it shall be replaced with the identifier of the
Java process. If the command string contains spaces then it must be surrounded
by quotation marks.
java -XX:OnError="gcore %p; echo 'Process %p has crashed.' \
| mail -s 'Java Crash' firstname.lastname@example.org"
This runs the gcore command to create a core image and then emails
email@example.com to alert them of the crash.
java -XX:OnError="userdump.exe %p"
This runs the userdump.exe utility to generate a dump file (assuming that
userdump.exe is available from the PATH environment variable).
The default value of -XX:OnError is empty, i.e. no action is performed.
Arguments Related to -XX:OnError:
TODO: link to -XX:OnOutOfMemoryError
If you have additional comments, interesting experiences or even point of disagreement with this JVM argument description, please leave a comment. Your
insights will help the entire 10+ million java developer community to develop
one standard source of documentation for all the JVM arguments.