@Override compile error, implementing an interface (eclipse jdk1.6.0_23 linux)

jsoc picture jsoc · Feb 14, 2011 · Viewed 15.7k times · Source

I am getting compile errors in eclipse when using the @Override annotation for a class that is implementing an interface.

Compiler compliance level is set to Java 6.0.

I am using the latest version of the 6.0 jdk.

Error: "The method {methodname} of type {classname} must override a superclass method"

Same code works fine on mac with comparable configuration.

public interface ChannelIF {
...
    public boolean canSendNarrowcast();
    public boolean canSendBroadcast(); 
}

public class FacebookChannel implements ChannelIF 
{
...
    @Override
    public boolean canSendNarrowcast() { return true; }

    @Override
    public boolean canSendBroadcast() { return true; }
}

Answer

Asaph picture Asaph · Feb 14, 2011

This feature is only valid in Java 6 and higher. I see you are using jdk 1.6. That's good. Possible cause: You are compiling with -source 1.5. Is this the case? If so, can you change it to -source 1.6?