10

I wish the run command (usually default to CTRL+F11 combination) of a Java project (and C++ if you know it too) to automatically close the previous process (or all processes, if it's easier) started by it before it runs a new instance.

In short, running a project should also close previous app instance. Is it possible?

Maybe it's possible to add code to the app itself, and disable it once I don't need it anymore? I want it since it's annoying to close the app each time. I don't need so many instances of the app.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
android developer
  • 114,585
  • 152
  • 739
  • 1,270
  • Have you found any solution? – kukis Aug 17 '15 at 10:27
  • @kukis No, this was asked a long time ago. But, I think you can find the current processes, and kill those that are of your app, which aren't the current one. – android developer Aug 17 '15 at 17:55
  • You might want to look at what @JonahGraham is doing with Launch Groups. See his answer to my question here: http://stackoverflow.com/a/33041696/367605 – KlaymenDK Oct 12 '15 at 23:13

3 Answers3

4

In Eclipse Neon go to Window -> Preferences -> Run/Debug -> Launching and in the Launch Operation section check:

[X] Terminate and Relaunch while launching

Terminate and Relaunch while launching

Robert Mikes
  • 1,179
  • 8
  • 19
1

Easier said than done. I suggest you terminate the process yourself by clicking on the little red stop icon in the console or by terminating the main thread from the threads view in the debugger perspective.

Chris Gerken
  • 16,221
  • 6
  • 44
  • 59
1

That's not possible with Eclipse built-in features. The easiest way to automate this seems to be

  • Install the launch group feature from CDT (you only need the mentioned feature) or the EclipseRunner plugin. They allow creation of "batch" launch configurations.
  • Create an external run configuration with a "kill" command (depending on your operating system), which can kill your application process based on the application name.
  • Create a batch launch group with one of the two plugins mentioned above, where the "kill" configuration comes first and your normal launch configuration comes second.
Community
  • 1
  • 1
Bananeweizen
  • 21,797
  • 8
  • 68
  • 88