I would like to know how to stop an application programmatically mid-way, if a certain condition is raised. I do not want to code as System.exit(1) as it will terminate the entire JVM and more than 1 application running in the JVM will be shut down. My goal is to shut down only one application (among more than one) that is running in the same shared JVM. The application me be in the process of starting and if a certain condition is encountered, I want to stop the application from starting and shut down only that the application.
I was thinking that throwing a RuntimeException will stop the Spring based application from starting. But that is not true. The runtime exception was thrown, but that did not stop the application from starting.
Is there a way to stop the application from starting (and eventually stopping it), if a certain condition is raised?
Again, not coding as System.exit(1) that would trigger shutdownhook of the entire JVM.
Would like to find a solution for both stand-alone and web-based
Java application.
I am using WebSphere 6.1 as application server.