A: 

Try doing a rebuild. I've found that the red x's don't always disappear until a rebuild is done.

mdec
+5  A: 

yeah, this happens sometimes for no apparent reason. You can go to the "Problems"-Tab (right next to console output) and see the error message, so maybe you can narrow it down that way.

Jan Gressmann
I specifically get it when another non-Java component fails validation (a good example would be an XML file, like spring's or maven's).
Spencer K
if you can see any problem in the problem view, that's apparent reason. I haven't yet seen any error with no apparent reason :)
nanda
+1  A: 

Sometimes there are build path errors in .project, and you need to switch to Resource view to actually see the file that is causing the error.

JeeBee
A: 

I've run into a similar problem many a time, what happens usually for me is that a java file will say it won't compile in the text editor but in the package explorer it will say it's compiling fine.

Sometimes doing a 'rebuild' or 'clean-build' doesn't work, the files don't actually get built (one has to presume that eclipse thinks the files it has are up to date) and when this happens I usually open up the java build path and just move one of my dependencies down/up the pecking order. This forces eclipse to do a rebuild of everything and it always seems to work.

If you're still having problems try copying the project and seeing if you get the same behaviour and at a last ditch attempt post a bug for eclipse, it may take a while for them to fix but at least you know that you're being heard.

PintSizedCat
+1  A: 

Try to clean the project and rebuild it.

flash
A: 

To add to the previous answer, an extreme way of "cleaning" your project is to delete it (that is deleting its reference from the workspace, not deleting the actual files), and then re-import it.
Sometimes, it helps...

VonC
A: 
Alfred B. Thordarson
A: 

As others have said, bad file references in the build path is often the culprit.

Usually a .jar file that has been moved/deleted. Eclipse expects to find everything referenced on the build path at the location specified, and will complain if not.

madlep
A: 

FindBugs also puts a red-x against files/packages to indicate static code analysis errors.

Rahul
A: 

I have run through this. My case was more involved. The project was packaged fine from maven command line.

Couple of things I made. 1. One class has many imports that confused eclipse. Cleaning them fixed part of the problem 2. One case was about a Setter, pressing F3 navigating to that Setter although eclipse complained it is not there. So I simply retyped it and it worked fine (even for all other Setters)

I am still struggling with Implicit super constructor Item() is undefined for default constructor. Must define an explicit constructor"

A: 

So upon finding that there could be a missing package in the buildpath, thus the red x against the main project, to remove this:

1) go into "Configure Buildpath" of project 2) Java Build Path -> Source Tab - you should see the red x against the missing package/file. if it no longer exists, just "remove" it.

red X begone! :)