android developer
android developer

Reputation: 116030

Close Java app before each run in Eclipse

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.

Upvotes: 10

Views: 2991

Answers (3)

Robert Mikes
Robert Mikes

Reputation: 1431

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

Upvotes: 4

Bananeweizen
Bananeweizen

Reputation: 22080

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.

Upvotes: 1

Chris Gerken
Chris Gerken

Reputation: 16390

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.

Upvotes: 1

Related Questions