Hello,
I'm interested in different approaches to gracefully shutting down a Java command line program. Sending a kill signal is not an option.
I can think of a few different approaches.
- Open a port an wait for a connection. When one is made, gracefully shutdown.
- Watch for a file to be created, then shutdown.
- Read some input from the terminal, such as "execute shutdown"
The third one is not ideal, since there is often program output pumped to the screen. The first one takes too much effort (I'm lazy). Do most programmers use the second option? If not, what else is possible/elegant/simple?
Thanks in advance. Mike