Usage:
• -XX:OnError=<command>
The command parameter may contain the special sequence %p, which is replaced by the process identifier of the JVM process.
Description:
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.
Examples:
Linux/MacOS example:
java -XX:OnError="gcore %p; echo 'Process %p has crashed.' \
| mail -s 'Java Crash' operator@acme.com"
This runs the gcore command to create a core image and then emails
operator@acme.com to alert them of the crash.
Windows example:
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).
Default Value:
The default value of -XX:OnError is empty, i.e. no action is performed.
Errors:
None
Arguments Related to -XX:OnError:
TODO: link to -XX:OnOutOfMemoryError
NOTE:
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.
Edit your Comment