A few days ago a new feature was committed to the Eclipse repository: Terminate and Relaunch. When enabled, Eclipse will terminate all currently running processes of a launch configuration before relaunching it.
This feature is particularly useful if the process to launch holds a unique system resource. For example, a servlet container that listens on a particular port will throw a BindException if that port is in use by a previously launched instance. With the Terminate and Relaunch, setting enabled, these types of errors will be a thing of the past.
To use the new feature, enable the option on the Run/Debug > Launching preference page like shown below.
And that’s it. Whenever you restart a launch configuration through the main toolbar, all active processes of that launch configuration will be terminated first.
In order to temporarily toggle the preference setting, you can hold down the Shift key while selecting the Run or Debug button.
Note, however, that Terminate and Relaunch is restricted to the Run and Debug toolbar buttons. Using the key bindings F11 or Ctrl+F11 for example will not consider this preference. I have added a corresponding request in the bug tracker and hope that this unfortunate limitation will be fixed before the final release.
The feature will be available in Eclipse 4.6 (Neon) M7. If you can’t wait that long, it is already included in I-builds >= 20160417, available from here:
By all that activity in Eclipse, I wasn’t lazy either. If you use the Launch Dialog from the Extras for Eclipse package, the Terminate and Relaunch option will also be considered. And there is no need to wait for a new version of Eclipse either. The feature is also available for all recent versions of Eclipse (4.4/Luna or later). You can even change the preference from within the dialog’s drop-down menu:
To be compatible with the upcoming version and older versions of Eclipse, Extras for Eclipse uses the same preference key as the new Eclipse feature.
Extras for Eclipse with support for Terminate and Relaunch, can be installed or updated from this software repository:
or drag the icon to your running Eclipse to install from the Eclipse Marketplace