When using Tomcat from Eclipse I often forget that one instance is already running. Then pressing CTRL+F11 again causes another launch. That causes this helpful message:
Several ports (8005, 8080, 8009) required by Tomcat v8.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).
Then you have to stop previous instance by red stop button. There is, as far as I know, no way to stop Tomcat by keyboard shortcut.
Also, when I need to restart Tomcat I need to stop it first by clicking on stop button. Then there is CTRL+F11 shortcut. Oh, well…
So I had to invent something. There is Launch group funcionality that seemed as viable path.
First, I have created following unittest. It tries to kill Tomcat server. It will work on Linux, for other systems you have to change processBuilder.command line. Also, there is simple check that this unittest is running on development environment - just checking that logged user is me. I am sure you can made up something smarter 😉
Then just create unittest run configuration:
I guess you already have your Tomcat configuration:
And then combine Unittest and Tomcat into launch group (do not forget to set Wait until terminated). I use unittest because it is easiest way to launch some code from Launch group.
Press Run and voila! Before new instance of Tomcat is started the old one is killed.
Warning: It is quite a redneck hack that should not be used outside development environment.