I have a annoying problem with @Override
annotations in Eclipse. Often when i import working projects on a new PC, Eclipse marks some of the @Override
annotations as wrong. If i remove the annotations everything is fine and Eclipse also indicates that the methods are overriding the parents methods but adding the Override annotation causes the error again. I am currently working on an Android project so it might be a problem with Android and not with Eclipse..

- 12,717
- 29
- 108
- 202

- 13,173
- 14
- 66
- 90
-
possible duplicate of ['Must Override a Superclass Method' Errors after importing a project into Eclipse](http://stackoverflow.com/questions/1678122/must-override-a-superclass-method-errors-after-importing-a-project-into-eclipse) – cHao Sep 04 '11 at 02:23
-
it might help to mention duplicate question at http://stackoverflow.com/questions/1678122/must-override-a-superclass-method-errors-after-importing-a-project-into-eclipse ... but I don't know how to mark it as such – Richard Le Mesurier Apr 05 '11 at 14:37
4 Answers
This is most likely because you are switching between Java 1.5 and Java 1.6. In 1.5 you couldn't mark interface implementations with @Override, but you can in 1.6.
A quick Google search turned up this good explanation of the difference in this annotation between the two versions: http://www.techienuggets.com/CommentDetail?tx=38155
Semantics of @Override is different in JDK 1.5 and JDK 1.6. In JDK 1.5, the @Override annotation is not allowed for implementations of methods declared in an interface, while they are allowed in JDK 1.6. For more information, see:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5008260 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6399361 http://blogs.oracle.com/ahe/?entry=override
It is fact that the description of the Override annotation was not updated in the JDK API docs. This has been reported as a bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6501053bugdatabase/view_bug.do?bug_id=6501053

- 398,270
- 210
- 566
- 880

- 183,023
- 24
- 297
- 295
-
Sorry, newb here, what can one do to get rid of these errors? I updated my Java Code compliance level to 1.6 and I'm still seeing the error, perhaps something else is wrong. – SSH This Jan 08 '13 at 04:04
There are a few places where Java Compiler settings are configured.
One way is to Window->Preferences->Java->Compiler->Compiler Compliance Level -> set 1.6 or above
.
Another way is right click on the Project->Properties->Java Compiler->JDK Compliance -> Select 1.6 or above.
Also You can unselect "Enable Project Specific Settings" , this will eliminate future JDK compiler compliance errors. Remove Multiple instances of JDK Versions , unless different projects need them.

- 29,068
- 10
- 64
- 102

- 523
- 12
- 15
-
1This solved my issue. My Eclipse preferences were at 1.6 and always had been, but my project somehow got bumped down to 1.5. – kjl Jun 11 '13 at 16:02
Make sure the used Java SDK is up to date and that eclipse use the right SDK version (if you have more than one installed) and treats your Android project with the right SDK version...

- 57,492
- 25
- 134
- 150