Friday, September 17, 2010

Eclipse: Class file name must end with .class

Today after I switched to another workspace to work on another CVS branch. I got error in Java search "Class file name must end with .class" when I type Ctrl+Shift+G (for reference in workspace).

Options I tried:
  1. Clean all projects and rebuild workspace (not work)
  2. Close the projects and reopen again (not work)
  3. Close Eclipse and start again (not work)
  4. Add -clean in Eclipse startup script (e.g. C:\Workshop\eclipse\eclipse.exe  -clean), and this worked!!
Another option I didn't try:
     a.  Close Eclipse
     b.  Delete <workspace>/.metadata/.plugins/org.eclipse.jdt.core/*.index
     c.  Delete <workspace>/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt
     d.  Start Eclipse again 


Root Cause:
Unknown, but mostly like it is Eclipse cache issue. My Eclipse version is as below
Eclipse Platform
Version: 3.4.1
Build id: M20080911-1700

1 comment:

  1. Thank you for the "options" you suggested.

    I had the same trouble but couldn't fix it even with de option "4" you tried.

    So I continued your suggestions and it worked fin after option "b"