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.
This question is related to
java
eclipse
interface
annotations
syntax-error
Check also if the project has facet. The java version may be overriden there.
Project specific settings may be enabled. Select your project Project > Properties > Java Compiler
, uncheck
the Enable project specific settings
or change Jdk 1.6
and above not forgetting the corresponding JRE
.
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 me
You can also try Retroweaver to create the Java5 version from Java6 classes.
Use Eclipse to search and replace (remove) all instances of "@Override". Then add back the non-interface overrides using "Clean Up".
Steps:
By configuring that the IDE projects are setup to use a Java 6 JRE or above sometimes does not remove the eclipse error. For me a restart of the Eclipe IDE helped.
Even after changing the compiler compliance setting to 1.6 or 1.7 from windows tab, then prefernces, then java, then compiler and setting the compiler compliance, I was still having this issue. The idea is that we need to go the the project folder, right click, Java and set compiler compliance to 1.6 or higer. This worked for me.
Do as follows:
Project -> Properties -> java compiler ->
You could change the compiler settings to accept Java 6 syntax but generate Java 5 output (as I remember). And set the "Generated class files compatibility" a bit lower if needed by your runtime. Update: I checked Eclipse, but it complains if I set source compatibility to 1.6 and class compatibility to 1.5. If 1.6 is not allowed I usually manually comment out the offending @Override annotations in the source (which doesn't help your case).
Update2: If you do only manual build, you could write a small program which copies the original project into a new one, strips @Override annotations from the java sources and you just hit Clean project in Eclipse.
I understood your problem, change your jdk from your jdk to greaterthan 1.5
Source: Stackoverflow.com