So i have my program, but i don't want it to be able to be closed. I know its not possible to make it 100% unclosable but this method seems like it would work the best.
I realize that you can addShutdownHook
, but this will not work if the process is killed in from the operating system, using Task Manager (Windows) or kill -9
(Unix). Obviously, if I have a second process running and the main one is killed it can just re-run the main one again, which makes it much more reliable.
So, I want to know how to create a watchdog process in Java that monitors my actual Java application to detect if it has been closed, then if it has been closed it re-executes the program.