Eclipse not recognizing imports in same project

12.2k Views Asked by At

From time to time, Eclipse (Indigo) complains that certain classes in my projects cannot be resolved to a type. Even it shows the class in popup list, clicking import (see image) does not add the import statement! Even if I add it manually, it doesn't recognize it (and underlines the import package).

  • This happens only in certain projects.
  • Unresolved types are in the same project! (not in other dependencies)
  • cleaning the project does resolve this, but only temporarily.
  • My application consists of multi-module maven based projects.
  • All projects are maven-based.

Not recognizing imports

4

There are 4 best solutions below

0
On

Right click on the project -> Maven -> Update Project...

Check (Force Update of Snapshots/Releases)

1
On

Right click on your project name ->Maven ->Update Project

0
On

For those not using Maven, simply deleting the project (and possibly re-cloning it) has reliably worked for me.

1
On

This just happened to be in Eclipse Neon.2 (2016 release) on a non-Maven project. Refreshing / updating the project did not help, but I was able to fix this without recreating the project:

  1. Go to Properties → Build Path → Source
  2. Remove all source folders in the build path, click Apply.
  3. Add them all back, click Apply.