Where does Eclipse save the list of files to open on startup? - eclipse

Question: where does Eclipse store the list of files it opens on startup?
Background: Having installed a plugin into Eclipse which promptly crashed, my Eclipse workspace is in a bit of a state. When started, the building workspace task pauses indefinitely at 20%. Before I uninstall the plugin I want to give it another chance. I have a feeling that the reason Eclipse is pausing is because of a file which was opened when it crashed, which it tries to reopen on startup. If I can stop this file from opening on startup there's a chance I may be able to coax the plugin to behave. The problem is I have no idea where that list of files is persisted between runs of Eclipse.
...a second before I posted this question, I realised I could just delete the file causing the problem (duh). However, the search has frustrated me enough to want to find the answer.

In your workspace the following file contains your workbench information:
.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml
It is possible to delete it (or edit it but that requires some fiddling around I suppose) without breaking your workspace, the file gets regenerated by Eclipse. When you delete it all workbench related settings are lost (ie all editors are closed), but your projects of that workspace stay intact.
Edit: in Eclipse 4.2 the file is
.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi

Related

Why does my Eclipse takes so much times to clean files?

I'm using Eclipse Kepler on Windows 7 and recently it became more and more frequent that it takes lots of time when it has to delete files. For example in these contexts:
mvn clean launched from Eclipse
cleaning output folder in case of automatic projects build by Eclipse
deploying a war on a server (deletion of the previous deployment)
I've checked this old question but working in a fresh new workspace has no effect.
I may have a clue: to gain some time I 'help' Eclipse by deleting the files myself with Windows Explorer. Windows often launches a pop-up saying that I need admin right to do that. I just hit Enter (I am admin user) and the files are quickly deleted. If Eclipse had no right to delete the files I would have expected an error, instead it just takes much more time to actually delete the files.
Why could be the cause of that? Knowing that the clue may or may not be relevant.
For the record: no solution has been found to the problem. I got a new desktop with a fresh Win7 image and I don't have the problem, working with the same Eclipse projects.
This would indicate that the problem came from a misconfiguration of the Windows user permission. Sadly, no more details available.

Is there anything to prevent re-importing all projects when Eclipse crashes?

Eclipse has bugs. It crashes, it freezes. And even if it doesn't the underlying OS might have its problems too. It is a fact of life.
The problem is that every time the Eclipse was brutally terminated, I am forced to delete the .metadata/.plugins/org.eclipse.core.resources folder, otherwise Eclipse wouldn't load the workspace at all.
But when I do this, the Eclipse forgets about projects in project explorer. Re-importing it again is not that much hassle, but it gets more and more annoying the more projects I work on and the more frequently the Eclipse needs to be terminated.
Is there any way to prevent the need to re-import all projects? Firefox for example, when terminated brutally, doesn't need to loose the information about the current session, because there are addons (e.g. Session Manager) that can revive old working session.
Or maybe there is a way to automatically repair the broken data in .metadata/.plugins/org.eclipse.core.resources? (It might not be that easy, since all files are binary).
Or maybe there is a way to automate workspace importing? Running such a script will be a huge time-saver.
Things I would try in order:
Start eclipse with -clean flag: ./eclipse -clean
Delete the .lock file: workspace/.metadata/.lock
Inspect the log files: workspace/.metadata/.log
Delete the .snap file workspace/.metadata/.plugins/org.eclipse.core.resources/.snap
If you are using eclipse4, delete workbench file: workspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi
Delete the project .markers.snap files workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/*/.markers.snap
Edit: .snap file can be named .snap or .markers.snap depending on your eclipse version

Eclipse crashed and deleted all my work

Eclipse crashed and deleted all project files, including written by me and XML files from another program which were not related to Eclipse.
Is it possible to force Eclipse or JVM to use trash can, so that if it goes mad and delete everything, files could restored.
UPDATE
Files were definitely wiped out. This was checked with third party file managers. Also entire disc were searched for traces.
Some good news is that Eclipse history remained. This allowed to restore some files I changed from Eclipse. But this project was consisting of multiple other files, that were written not by me (taken from other libraries) or contained some data I was editing not in Eclipse (like XML or raw data).
All these files were wiped out by Eclipse.
If this would not happen to me I would also say it is unlikely. But it has happened.
The problem is somehow related with
(1) Eclipse
(2) Maven (m2e)
(3) Eclipse RCP
(4) Tycho
At some moment Eclipse started to show numerous error windows and I was to kill the process. After that I found files absent.
So I need some extra protection layer.
UPDATE 2
Crash repeated. This is a message during file wiping out:
This time I was not using Maven and Tycho.
UPDATE 3
Third crash.
Crash occurs only after error Application ... could not be found in the registry, which itself buggie.
UPDATE 4
Still unable to reproduce situation from scratch...
UPDATE: I think from this question you were working on an Eclipse RCP plugin or something like that when this happened.
So you probably broke your Eclipse in some fashion. Do not trust anything Eclipse tells you at this point! Look at the actual filesystem!
Eclipse crashed and deleted all project files, including written by me and XML files from another program which were not related to Eclipse.
That's highly unlikely. (Especially if those XML files were not in the workspace. But even if they were, it's very unlikely.) You probably opened a new workspace without realising it, or maybe Eclipse has some bug where it won't show you files that are actually there. Or maybe you accidentally switched to the wrong view (in Java the normal view for files is Package Explorer, if I remember correctly).
Or maybe you were storing your workspace on a USB stick (aka pen drive) or network drive and you accidentally disconnected from it without realising it.
Check in the workspace (the actual workspace you were using at the time, not the workspace you are now using, which, as I said, might not be the same thing), using Windows Explorer (if you are using Windows) or Finder (if you are using a Mac) or using ls (if you are using something else). Are the files really gone?
This Was My Fault
I was setting up a workspace location pointing to project folder and also setting clear workspace checkbox.
::shame::

How to clean window history in Eclipse

Right now I'm having this issue in Eclipse where I have an XML file open that's really big in which it almost crashes Eclipse. However this file being opened is saved in my window history, therefore I restart eclipse, it tries to open this massive file again. How do I clear the opened window history in eclipse?
I would prefer not having to clear my workspace entirely as I have mylyn data I want to keep. I've tried using Eclipse clean but this doesn't seem to do anything related to opened windows.
Your workbench information are saved in this file in your workspace:
.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml
or depending on your eclipse version:
.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi
You can delete it and eclipse will recreate the file, you can also try to edit it, but it's a big file and may be hard... Deleting this file all workbench related settings are lost but your projects stays intact.
Go to Preferences and search for 'workspace'. You will see the list of workspaces that you can delete.
Some alternatives:
Move or rename the offensive file so that eclipse is unable to open it.
File->Switch Workspace->Other to load a new workspace copying your workbench layout.
Just some thoughts, my experience is closing a file and then the program means that the program will not attempt to open the file once launched again.

Eclipse : how to prevent it from loading all the open files on startup?

I had 100+ files open in the previous session, then closed eclipse. On a restart, eclipse just hangs with extremely high mem usuage. This problem doesn't happen with only 50 files opened.
How to prevent eclipse from loading all the previously opened files on startup? It would make more sense that the files are loaded on demand, i.e. load when focused.
I am using CDT.
When the Eclipse is open, close those projects which you dont want for now. Right Click on the project name and select "Close Project". Next time you restart the Eclipse the closed projects should not get loaded.
This is not possible. Eclipse will always restore the same state after a restart.
You can mitigate the effects with little fuzz by
closing projects (right click the project you're not working on, select Close Project
closing unrelated projects (right click the project you're working on, select Close Unrelated Projects
using Mylyn! Mylyn will ensure that files you stopped working on will be automatically closed. (But it does more than that. See for more info e.g. help.tasktop.com and www.tasktop.com (pdf)) It takes some time getting used to it, but I eventually fell in love with it. If you don't switch tasks that often, you can just create one general task, activate it and keep working in that one forever.
opened a bug on eclipse, after the help from there, it turns out this is caused by the vrapper plugin I installed. For more details, https://bugs.eclipse.org/bugs/show_bug.cgi?id=377368