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.
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.
What is the short cut in eclipse to terminate debugging/running?
Is there a keyboard shortcut for stopping the current console in Eclipse?
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.
Related
"Debugception!"
You may notice that within the first 15 seconds of this YouTube video (from 1:01:01 to 1:01:16), Markus Persson (aka "Notch", creator of Minecraft) has somehow managed to save/update an application and attach a debugger to it while it was already under the process of being debugged, supposedly all with a simple keyboard shortcut. The previously coded application somehow magically became the newly edited one, and seemingly without relaunching it or spawning a new process... It's possible that this is just some form of locally remote debugging, but something about it just doesn't seem quite right.
I've spent several days Googling and asking around on how he was able to do this, yet to no avail. I've found no such option under Eclipse preferences, and whenever I try to save & debug an already running application, it simply launches a separate instance of the newly updated application, side-by-side with the older, outdated one.
Am I missing something? How was this possible?
How was he able to utilize such an astounding, powerful debugging feature?
Thanks in advance!
Update
Okay, so this appears to be a standard feature specific to Eclipse.
Coming from a background in NetBeans and Visual Studio, I'm astounded that this doesn't seem to exist elsewhere (or at least in NetBeans!)...
This is a built-in feature of Eclipse. If you edit a method while the program is running in debug mode, it will compile the new method, and replace the old method with the new version. If some thread was already running that method, it will jump back to the beginning (AFAIK; this might only happen when the program is paused).
You don't need to re-launch the program or set any special preferences. Just edit and save, and the magic will happen.
Eclipse can't always figure out how to merge your changes into the running program - usually if you changed anything outside a method body (including the method's parameters or return type). In this case, you will get a warning dialog, with the option to stop the program, restart the program or ignore the changes.
Sorry in advance. This is a really vague question because I have no idea whatsoever what is going on. I have a Java Swing GUI desktop app that I wrote in NetBeans. While inside of NetBeans, the app works fine and passes all of the tests that I have thrown at it. I've been developing this app over the past several months, deploying it at various phases of its development.
Yesterday, I finished adding and testing some new functionality. I built the application and put it on another computer. I then went to run the program (outside of NetBeans) straight from the jar file. While in the new areas (JDialog boxes), the program crashes. Since I am not in an IDE, I have no feedback to see what is wrong.
The only thing that I can think of (and this is lame) is that I added some switch statements that switch on strings, which I know to new to 1.7. I was previously developing in 1.6. Otherwise, I can think of no reason that the program should work flawlessly inside the IDE, but crash outside of it.
Can anyone offer any suggestions for how I should approach this? I'm at a complete loss.
Thanks very much.
The next debugging step for you is reducing the size of your program until it doesn't crash, then seeing what change you made worked. That should either make the answer obvious or give you a good question to post on SO.
Your idea that it might have to do with switch statements tells you to try:
removing them
removing and compiling on JDK 6 and see if it works
Those are reasonable ways to reduce your program size to see if you can make it run.
I would start from collecting a crash dump data.
If you run the UI on windows you could use DrWatson
If you run the UI in Linux , By default the heap dump is created in a file called java_pidpid.hprof in the working directory of the VM. unless you specify the path yourself by adding this -XX:HeapDumpPath= option to your UI java options.
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.
In Eclipse Neon go to Window -> Preferences -> Run/Debug -> Launching and in the Launch Operation section check:
[X] Terminate and Relaunch while launching
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.
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.
I created a new project using the play console
now, by default I got in my views directory two files:
main.scala.html
index.scala.html
I want to add a new view file. I call it "forums.scala.html"
now, I know that in order to render a view you need to do this:
views.html.forums.render("Forums");
the problem is that the intellisense doesn't recognize "forums"
but index and main it does recognize.
I've noticed those files:
class_managed/views.html/index.class
class_managed/views.html/main.class
but there is no forums.class so I suspect this is the problem.
I tried to build the project, but it didn't help.
so, what is the solution?
thanks
Your new views are compiled to managed sources after next browser hit if you are using play run for starting Play in dev mode.
If you'll use play ~run it will try to compile it as soon at it will recognize change in the file.
Finally if you started your app in production mode ie. via play start you have to stop it with ctrl+c and run again. Anyway, developing application in production mode is just a bad idea :)
Depending on your IDE most probably you'll need to refresh file structure to allow it find freshly created managed sources.
right click on ther project and click refresh, that worked for me - found it in another thread.
Found the solution.
running "compile" command did the work.
I understood that intelliJ do it auto, so I will probably use it instead of eclipse.
cheers!
If you want to program in scala, my recommendation is to forget about intellisense. Eclipses scala-ide is quite buggy, dont know about netbeans. And because of nonstandard layout of play2 application, non std development tools (play console), it becames even more handy to use simple text redactor (like sublime or textmate) with good old open-folder-as-project feature.
I'm new to Java (come from C++/.NET background) and am experiencing very strange error. I am developing w/ Eclipse IDE on Windows XP on my local desktop. It seems that for some reason, an older (and of course buggier) instance of my application stays running for some very odd reason which I cannot understand.
Even when I close eclipse, this old version of my application is running in the background. So unless I reboot, when I try to test new version of the code, this 'old, rogue instance' is fighting for the resources that are used (files on a share) with the newer (hopfully less buggy) version of the code.
Has anyone experienced this? Does the JVM cache old versions of your Java application for some reason? What am I missing here? When I reboot my machine, the instance finally dies...
I was ripping my hair out trying to figure out why the new version of my code still had the same old bug until I realized this was happening... shrug
Thanks for any help!
Do you by chance either run your program multiple times, or have forgotten to close one instance of it prior to re-running it from Eclipse?
One thing, that is not very obvious when using Eclipse, is that it allows to run any number of instances of Java programs simultaneously. When you have the Console view active, you have the option to terminate the latest launch.
To switch the console to a different launch (if there are multiple running) you can select from a list, by pressing the "Display Selected Console" icon, which is the monitor icon to the top-right in the Console view.
You can also remove any and all terminated launch console outputs from the Console view, by pressing "Remove All Terminated Launches", if every launch have been terminated it should now display "No consoles to display at this time", otherwise the next-newest running launch will be brought to the top.
If this isn't the problem, and indeed Eclipse have lost track of a launch (which is quite rare, but can happen - especially if you spawn sub processes yourself), you can safely terminate any run-amock java.exe process from the Task Manager, as Eclipse runs wrapped in a Windows executable on the Windows platform.
Java applications run under "java.exe", so you can look for that in the task list. Sadly, if several Java applications are running at the same time, it's hard to tell which is which.
I'm not terribly familiar with Eclipse, but it seems like Eclipse should tell your old version to terminate when you close Eclipse. The JVM doesn't cache past versions.
Hope this helps.
I had a problem like this as well. I would try to run the program after making changes, and it would run the older version of it, and still report errors and stop on lines that I had even commented out. I tried micdah's solution, but there were no java.exe processes in Task Manager. I solved the problem by killing the Eclipse process from the Task Manager, which closed the program without saving Eclipse Workspace settings. When I relaunched, everything I had saved in the .java files launched normally.
Could be a bug in Eclipse. Could be some code in your application that's spawning a new process. Impossible to tell from over here.
If you haven't already, check out the jps tool, which is included with the regular JDK. It might make it easier to diagnose the problem.