I wrote the following code:
public class JavaErrorTest {
public static void main(String[] args) {
if (1 < 2) {
throw new OutOfMemoryError();
}
}
}
Then I invoke it like:
$ java -XX:OnError="echo %p" JavaErrorTest
And in my console, I get the following:
Exception in thread "main" java.lang.OutOfMemoryError
at JavaErrorTest.main(JavaErrorTest.java:5)
Somehow, I suspect that the -XX:OnError
JVM option is not being picked up. I'm invoking java using cygwin, using jdk 1.6.0_30, running under Windows 64 bits.
What am I doing wrong?
EDIT
Following command produces the same output:
$ java -XX:OnOutOfMemoryError="echo %p" JavaErrorTest