I have an existing project that uses @Override
on methods that override interface methods, rather than superclass methods. I cannot alter this in code, but I would like Eclpse to stop complaining about the annotation, as I can still build with Maven.
How would I go about disabling this error?
Note: Due to project requirements, I need to compile for Java 1.5.
Check also if the project has facet. The java version may be overriden there.
Project->Properties->java compiler->
Enable project specific settings -yes Compiler compliance - 1.6 generated class files and source compatibility - 1.5
Project specific settings may be enabled. Select your project
Project > Properties > Java Compiler
,uncheck
theEnable project specific settings
or changeJdk 1.6
and above not forgetting the correspondingJRE
.Incase it does not work, remove your project from eclipse, delete
.settings folders
,.project
,.classpath
files.clean and build the project, import it back into eclipse and then reset your Java compiler. Clean and build your project
and eclipse. It worked for meUse Eclipse to search and replace (remove) all instances of "@Override". Then add back the non-interface overrides using "Clean Up".
Steps:
Using the
@Override
annotation on methods that implement those declared by an interface is only valid from Java 6 onward. It's an error in Java 5.Make sure that your IDE projects are setup to use a Java 6 JRE, and that the "source compatibility" is set to 1.6 or greater. Open the Window > Preferences dialog, and browse to Java > Compiler. There you can set the "Compiler compliance level" to 1.6.
Remember that Eclipse can override these global settings for a specific project, so check those too.
Update:
The error under Java 5 isn't just with Eclipse; using
javac
directly from the command line will give you the same error. It is not valid Java 5 source code.However, you can specify the
-target 1.5
option to JDK 6'sjavac
, which will produce a Java 5 version class file from the Java 6 source code.I understood your problem, change your jdk from your jdk to greaterthan 1.5