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.


13 Responses to “Eclipse: Class file name must end with .class exception in search”

  1. Greg Says:

    Thanks, that worked for me too!

  2. cimnine Says:

    Thank you so much. It worked for me too.

  3. Hey, this is a vert good tip!

  4. Thomas Nestler Says:

    Great, this problem was a great pain until I found your tip. Thanks

  5. konkona Says:

    thanks, My problem was fixed

  6. jangel Says:

    Thank you so much. It was useful for me.

  7. Tamas Says:

    Thanks you saved me

  8. Ben Says:

    Thanks, you’re a life saver!

  9. Hernan Rodriguez Says:

    Thanks, that works for me!

  10. Pipiniababashvantal Says:

    You are my hero! definitely!

  11. Just a developer Says:

    I got the same error message during “Organize Imports”. Thanks for the fix, it worked here also.

  12. Palaniappan Says:

    Thanks for the information.It really helped…

  13. rby Says:

    thanks bro , its worked here also :)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: