Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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; }
}
like image 790
jsoc Avatar asked Feb 14 '11 18:02

jsoc


3 Answers

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?

like image 197
Asaph Avatar answered Nov 02 '22 10:11

Asaph


I too have facing problem and just resolved. Change "Compiler compliance level" to 1.6 in Project->right click->properties->Java compiler.

like image 22
Chowdappa Avatar answered Nov 02 '22 10:11

Chowdappa


In eslipse can use different versions of compilers.

See сonfiguration in eclipse Preference->Java->Compiler "Compiler compliance level". You must choose "1.6".

like image 3
splean Avatar answered Nov 02 '22 09:11

splean