Tip of the Day: Fixing a "broken" Eclipse project

Post date: 17-Jul-2009 08:33:45

Starting with a new IDE, a new SDK and a new language is in intimidating project, and despite having done some mobile, Eclipse and Java development before there's still lots for me to trip over. Case in point: I tried to clean up SofaStream's codebase to check it into source control on it's Google Code project, and somehow upset my Eclipse project. I seem to do this once every few months using Eclipse - making some code or configuration change gets the project into an unusable, irrecoverable state and hours of research offers no solution for correcting it. In my case nuking some of the generated directories - 'gen', or possibly 'bin' - caused the 'src' directory to be marked as having errors, but with no source code was highlighted as being the cause of the errors. I was also seeing 'no classfiles specified' errors in the console, but couldn't see any clear way to correct this either.

Extensive Googling revealed a lot of similarly frustrated people, but no solution that worked for me - refreshing, double-checking the SDK path, I still couldn't build 'cause my source code was "broken". So I did what seems to be a recurring solution - I nuked (leaving source intact) and reconstructed the Eclipse project. This worked like a charm, even though I actually re-imported the same project files from the "broken" project - strongly suggesting that there was nothing wrong with my project at all, Eclipse was just having a deranged moment.

So if you see something similar in your own project (or you're using Eclipse regularly) - get comfortable with separating your codebase from your Eclipse project... and remember that throwing away the later is an option, if it seems irrecoverably broken.