Skip to content

CAUTION: This site hosts draft documentation for the next release. For published content of the latest release, visit


You can use this Oracle HotSpot option to run commands when a java.lang.OutOfMemoryError is thrown. This option is recognized by Eclipse OpenJ9™ and provided for compatibility.



where <command_string> is a command or list of commands to run when a java.lang.OutOfMemoryError occurs.

For example, the following command specifies that the java -version command is run if the Test application throws a java.lang.OutOfMemoryError exception:

java -XX:OnOutOfMemoryError="java -version" Test

If you want to run multiple commands, use semicolons to separate them within <command_string>. For example:

-XX:OnOutOfMemoryError="<java_path> <java_program>; cat file.txt"

The -XX:OnOutOfMemoryError option is equivalent to the following -Xdump option:


For more information, see -Xdump.