Archive for the 'Programming' Category

Eclipse: Class file name must end with .class exception in search

November 4, 2009

Eclipse is nice IDE but it has it’s own problems. This time the Java Search and Open Type -search produced an error saying “Class file name must end with .class”. Very helpfull. Fortunately almost all the answers in the world can be found in the Internet and so with a quick googling the solution to this annoying problem was found on Stack Overflow.

I had already tried Project -> Clean… and closing Eclipse, deleting all the built class files and restarting Eclipse to no avail as was the original question author. The right answer lies in deleting the corrupted search index which is explained in Eclipse bug’s #269820 comment.

How to delete the search index:

  1. Close Eclipse
  2. Delete workspace/.metadata/.plugins/org.eclipse.jdt.core/*.index
  3. Delete workspace/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt
  4. Start Eclipse again

This fixed the issue for me.