0

I am working on a project where my job is to crash the JVM by executing a program. In the JVM I have Tomcat running with a web app deployed in it. As soon as the JVM crashes I get "Page not found. Server may be down" error in the browser for the web app as with the JVM, Tomcat has also stopped.

Now, I want to generate a popup as soon as JVM crashes. The popup will say "JVM has crashed!". Can you please tell me how to write such a code?

Thanks in advance!

kajarigd
  • 1,299
  • 3
  • 28
  • 46

2 Answers2

0

UnInvoked finalize() methods should be called on jvm exit. You need to override finalize method in one of your classes and keep its reference alive till jvm is alive. On JVM crash this method would be invoked. But this cant be taken forward to browser i guss as your container threads would be killed once JVM crashes.

Vineet Kasat
  • 994
  • 7
  • 14
  • To me at least, "JVM crash" means the JVM exited abnormally, for example due to an invalid memory access in native code (either the JVM's own code, or third party code called via JNI). In that scenario, no finalizers will be run. And even in the case of a normal JVM exit, such as a call to System.exit(), finalizers only run if Runtime.runFinalizersOnExit() is enabled - it is disabled by default, and as its own documentation states, it is deprecated and enabling it is discouraged, since doing so can cause hangs during JVM exit. – Simon Kissane Aug 15 '15 at 22:33
0

Maybe you need another service monitoring the JVM's status.

When the JVM crashed or can not response, the server notify your page and alert.

lichengwu
  • 4,277
  • 6
  • 29
  • 42