Skip to content

@override annotation in JDK 1.6

I’m using JDK1.6. When I implement an interface and in the implementing class, if I give @override before my function names, Eclipse throws an compilation error. i.e. below code is wrong according to Eclipse.

public class SomeListener implements ServletContextListener {
    public void contextDestroyed(ServletContextEvent arg0) {
       // code
    /* other overridden methods here */

If I remove @Override annotation, then the code compiles fine. Does it mean that JDK1.6 does not require us to prefix the @override annotation anymore?


You probably need to set the compiler compliance level in eclipse. This can be found in Window->Preferences->Java->Compiler

If the compiler preferences are still set to 1.5 the compiler will barf on the override annotation.

Edit: Also check compiler compliance level on a per project basis if you’ve set those to anything else than default.