Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fix Eclipse java references database corruption?

Tags:

java

eclipse

How do I make eclipse rebuild the database of classes contained within a project or workspace? This is what it uses to make the "References" menu action work, what it uses for the "Add import" dialog, etc. Basically, it's part of the core usefulness of Eclipse. And now, it's only working for maybe 5% of my project.

I've run into this problem multiple times: something happens with eclipse, either through an OutOfMemoryError because I opened some huge file, or because a workspace just has months of hard usage.

Right now, I'm using Eclipse Galileo on Win32. However, I've had this problem on MacOS as well as with Europa and Ganymede.

In the past, I've trashed my workspace and started again, but today this is not an option. My last workspace backup is from last Friday, but that still means hours of work in restoration. Surely there must be another option?

EDIT: I've used eclipse -clean as well as rebuilt my project. This is a corruption problem somewhere in eclipse, not in my project.

like image 438
lucasmo Avatar asked Jul 22 '09 17:07

lucasmo


People also ask

How do I fix Eclipse workspace?

From eclipse.org, select Projects > Eclipse Project > Platform > Core, and then look for the workspace restorer plug-in on the development resources page. Be sure to also enter a bug report in the Eclipse Bugzilla with any available log information to help prevent such disasters from happening to others!

How do I force eclipse to recompile?

For Eclipse you can find the rebuild option under Project > Clean and then select the project you want to clean up... that's all. This will build your project and create a new bin folder. Save this answer.

How do I resolve an error in eclipse?

The Quick Fix dialog can also be displayed by right clicking on the error item in the Problems view and selecting the Quick Fix menu item.


3 Answers

First exit Eclipse. Next in your workspace directory, delete the .metadata/.plugins/org.eclipse.jdt.core/ directory. Next time you launch Eclipse, it will rebuild all of its internal indexes. Often cleaning of projects doesn't force all of that metadata to be rebuilt.

like image 200
Adam Batkin Avatar answered Oct 24 '22 02:10

Adam Batkin


If it's just on a project level, I recall that you can simply close the project (i.e. Project -> Close project), then re-open it (Project -> Open project). You shouldn't even need to restart eclipse.

like image 38
ireddick Avatar answered Oct 24 '22 02:10

ireddick


This worked:

  • Export preferences from your current workspace (File->Export->General->Preferences)
  • Switch workspaces to a new workspace
  • Import preferences into the current workspace
  • Import your old project into the new workspace (File->Import->General->Existing Projects into Workspace), choosing "Copy project"

That works for getting the references DB fixed. To get SVN (and presumably CVS) to work again:

  • Right click on project, choose Team, choose "Share project." Choose whichever type of versioning repository you were using and click next. Eclipse should realize that your project was already configured for this and just make you click Finish.
  • Update your sources with the repository.
like image 2
lucasmo Avatar answered Oct 24 '22 03:10

lucasmo