score:272
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
- Browse to Java > Compiler.
- There, 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's javac
, which will produce a Java 5 version class file from the Java 6 source code.
score:0
I understood your problem, change your jdk from your jdk to greaterthan 1.5
score:0
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.
score:0
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.
score:1
You can also try Retroweaver to create the Java5 version from Java6 classes.
score:1
Use Eclipse to search and replace (remove) all instances of "@Override". Then add back the non-interface overrides using "Clean Up".
Steps:
- Select the projects or folders containing your source files.
- Go to "Search > Search..." (Ctrl-H) to bring up the Search dialog.
- Go to the "File Search" tab.
- Enter "@Override" in "Containing text" and "*.java" in "File name patterns". Click "Replace...", then "OK", to remove all instances of "@Override".
- Go to "Window > Preferences > Java > Code Style > Clean Up" and create a new profile.
- Edit the profile, and uncheck everything except "Missing Code > Add missing Annotations > @Override". Make sure "Implementations of interface methods" is unchecked.
- Select the projects or folders containing your source files.
- Select "Source > Clean Up..." (Alt+Shift+s, then u), then "Finish" to add back the non-interface overrides.
score:8
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.
score:9
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
score:12
Check also if the project has facet. The java version may be overriden there.
score:41
Do as follows:
Project -> Properties -> java compiler ->
- Enable project specific settings - 'yes'
- Compiler compliance - 1.6
- generated class files and source compatibility - 1.5
Source: stackoverflow.com
Related Query
- Why does Eclipse complain about @Override on interface methods?
- Why does Eclipse mark interface methods public abstract?
- Why does Eclipse complain about dead code?
- Why does Eclipse complain about ambiguity in overloaded varargs method?
- Why does Eclipse complain about missing semicolon in my javascript?
- Why does Eclipse complain about unsafe type casting?
- Why Eclipse does not include annotations when implementing methods from a Java interface?
- Why does M2Eclipse complain about missing artifact when mvn command line doesn't?
- Why does Eclipse sometimes warn about arrays of arrays in JavaScript?
- Why does Eclipse warn about Java "unused variables" but javac does not?
- Why Eclipse puts @Override annotation on implemented interface methods (and then it doesn't work in Maven)?
- Why doesn't default Eclipse complain about unused method parameters?
- Why does eclipse make delegated methods protected by default?
- Why does Eclipse complain that the project specifies compiler compliance 1.8 but a JRE 11 is used?
- Why doesn't eclipse complain about this deprecated method?
- My class implements an Interface but doesn't override it's abstract methods. Why is Eclipse still compiling it without an issue?
- Why does Eclipse flag private methods with 'parameter is hiding a field', but not public methods?
- Why does my eclipse IDE run without compiler error when I create a non static inner class with static methods and variables?
- Why eclipse does not warn about using classes from newer java versions?
- Why does Eclipse automatically add appcompat v7 library support whenever I create a new project?
- Why does Eclipse Java Package Explorer show question mark on some classes?
- Why does my Eclipse project have phantom debugger breakpoints?
- Why does Eclipse take so long to update Maven dependencies?
- Why does Android Lint warn about String.format using default locale when explicitly using Locale.US?
- Why does my Eclipse Indigo crash on Ubuntu 13.04 with Oracle JDK 64bit?
- Why does Ubuntu 14.04 stick with (old) Eclipse 3.8 when 4.3 is out?
- Why does my Eclipse keep not responding?
- Why does Eclipse use Cp1252 encoding?
- Why does eclipse create a .settings directory?
- Why does Eclipse 'filter results from view' when searching?
More Query from same tag
- How does eclipse know what OSGi bundles there are that can be depended on?
- MyEclipse Professional on connecting with ms sql server is giving ssl error through db browser
- Programmatically importing an existing project into Eclipse
- In eclipse, how to have one project override class files of another project
- Netbeans why does some text appear bold in roboticket?
- Eclipse missing require source folder 'gen'
- jQuery Mobile + Phonegap :: Ajax "Loading" gif does not animate
- How can I fix "The markup in the document following the root element must be well-formed." error in eclipse
- setting up development environment for PHONEGAP
- How can I disable the hint window in EClipse
- Issues with Eclipse while working on and Android project
- Android recreate() functions in api 7
- How to put image in masterflow
- camera source code for android eclipse
- How do I get Tycho?
- Array Index out of Bounds in Eclipse
- Error in Eclipse when compiling code but not when is validated
- Navigation Drawer starts with the first item
- How to see a Clojure function's call hierarchy using Eclipse and CounterClockwise
- Create maven package
- How do i consolidate a bunch of projects from one git repo into a single folder In Eclipse Project viewer?
- com.amazonaws.services.lambda.runtime.events does not contain SQSEvent
- How to force the emulator to simulate a tablet
- Where is the "update site" list stored in the filesystem?
- Using Eclipse CDT for Pintool development
- How do you create a title screen for an android app? E.g. When the app is loading like Facebook
- Eclipse Plugin for custom Strg+Click hook
- How to open a project in eclipse ADT and automatically import LIbrary Projects dependencies
- save file from unit test to project tree
- How to make the button fit the same amount of the screen and be in the same place on android app