Eclipse error: "The import XXX cannot be resolved" Eclipse error: "The import XXX cannot be resolved" java java

Eclipse error: "The import XXX cannot be resolved"


Try cleaning your project by going to the following menu item:

Project > Clean...

If that doesn't work, try removing the jars from the build path and adding them again.


Obviously there are cases where there is a valid issue however Eclipse throws this error for no good reason sometimes. This is still (in v 2020-09) an old (2010) Eclipse bug that can be resolved by making a negligible change to the project settings.

touch .classpath

solves the issue, or go to Project > Properties > Java Build Path > Order and Export > make a meaningless order change > Apply. Changing the order back does not regress to the problem.


Clean the project. And double-check the jars being really on the build path (with no errors). Also make sure there is nothing in the "Problems" view.