5

I usually develop mobile apps for iOS and Android and I am used to launching projects repeatedly without asking if another instance is running or not, since the simulators will handle this for me.

When I use Eclipse to develop desktop apps, I face this problem since running multiple times the same project will result in multiple different instances. I would like Eclipse to be able to kill the previously-opened processes before running the new one. I've found this question, but this one addresses the problem to let a single instance of a Java application run, but this is not quite the point. I do not care if the final release will run one or two times, I just want to be able to run a single instance when developing, seamlessly like Xcode or Eclipse for Android do. Moreover, that solution will popup an alert when running the same project twice, but that's not a solution for me. Kill and run, that it.

Is it possible to change the run configuration of the project to achieve this without changing the source code, or is this achievable with a plugin or whatelse? I would like to find a completely automated solution that could make me work as if I were under Xcode.

Community
  • 1
  • 1
marzapower
  • 5,531
  • 7
  • 38
  • 76
  • Without knowing what you're doing... you could try deploying it to Tomcat, then hot deploy the code (in Eclipse of course) and all will be right with the world. – Bob Flannigon May 31 '13 at 14:42
  • It's a desktop app, as stated in the question. A libgdx project, to be more precise: https://code.google.com/p/libgdx/ – marzapower May 31 '13 at 14:43
  • this is still annoying but works: http://stackoverflow.com/a/16927496/1422630 – Aquarius Power Feb 02 '15 at 19:27

2 Answers2

3

No, it is not possible to change the Eclipse run configuration so that Eclipse stops existing instance before running new instance.

As an alternative, you might try setting a keyboard shortcut for "Terminate" action.

Community
  • 1
  • 1
kaliatech
  • 17,579
  • 5
  • 72
  • 84
  • 1
    Well, if Eclipse know how to "terminate" and how to "run", I believe it is possible to combine the two actions together ;) – marzapower May 31 '13 at 14:20
  • Possibly with a keyboard shortcut, although it doesn't seem straightforward. Others (including myself) want the same thing (although I have never gotten it to work reliably): http://stackoverflow.com/questions/15259857/is-there-a-keyboard-shortcut-for-stopping-the-current-console-in-eclipse . – kaliatech May 31 '13 at 14:22
  • I should also point out that when using Eclipse's hot swapping and/or JRebel, there aren't too many applications that require constant stopping/restarting to see code changes. – kaliatech May 31 '13 at 14:24
  • Yes, hot code swapping *could* be a solution, but when developing an event-base game that solution not always will work. Will break 50% of the time. – marzapower May 31 '13 at 14:26
  • By the way, using a shortcut to terminate the app before re-running it is as time-consuming as killing the app before switching back to Eclipse. If I forget to kill it (as I always do), I will not solve my problems with another shortcut :) – marzapower May 31 '13 at 14:28
  • Agreed on both points. I feel your pain, but afaik, there is no solution in Eclipse. The only decent workaround I can think of is to modify your code such that if it detects an instance running newer than itself, it self exits. – kaliatech May 31 '13 at 14:30
3

As a general solution to this, try:

Goto Window->Preferences, search for Launching.

Select the "Terminate and Relaunch while launching" option.

Press Apply.

Not sure if it would work while developing Android (not very common in Eclipse now), but good option to know.

dac2009
  • 3,521
  • 1
  • 22
  • 22