What icon is used for the file? If it is an outline J eclipse doesn't recognize the file as being a source file of the project.
If so, you need to declare the parent folder of your package a source folder, i.e. if the path looks like ".../src/my/package/MyClass.java" the "src" must be declared a source folder (right click -> Build Path -> Use as Source Folder)