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

我怕爱的太早我们不能终老 提交于 2019-11-30 17:29:38

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?

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

In eslipse can use different versions of compilers.

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

I just found that when using maven I needed to also modify the pom.xml to have the compiler plugin. I had all my settings properly specified, but I needed this one:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <inherited>true</inherited>
      <configuration>
          <source>1.6</source>
          <target>1.6</target>
      </configuration>
    </plugin>
  </plugins>
</build>

So, I kept having this problem, and after running through the above solutions a few times, seeing that my version of Java was set to 1.7 all the way down, not using Maven, and so just quitting and restarting Eclipse a couple times as @jdowdell suggested, after which, it would seem to work until the next time I implemented one of these. I realized that when I was re-starting Eclipse it was prompting me to save my files and I realized that my interfaces had not been saved, so the original method, the one being overrode, didn't exist on disk. And this is why quitting and restarting Eclipse fixes the problem.

tl;dr : Check that all your files are saved.

Sounds like your method signatures don't match. They must be the same, including things such as thrown checked exceptions. Post your code!

Check the Runtime library, the compiler settings are probably different

Right click on the project name, properties, Java Build Path, Libraries

Look at the version of JRE System Library, more than likely it's set to 1.5 or lower. Select JRE System library, then click remove Click Add Library, select JRE System Library, Next Then either Workspace Default, or

I had this same problem for about an hour, and then it seemed to mysteriously solve itself. I wish I know what I did. I had started with workspace settings set for 1.6, unwittingly having project settings set to 1.5 compatibility. I discovered this and changed project compiler settings to 1.6, which resolved some errors, but not the @Override issue for interfaces. Some combination of the following fixed it:

  1. Changing the jre back from jdk to the jre that Eclipse custom installed (or somebody, wasn't me).
  2. Disabling project specific settings in the compiler section, and also clicking Reset to Defaults, on both project and workspace settings for compiler.
  3. Quitting Eclipse and rerunning it as Administrator (I copied eclipse into Program Files on Windows from a .zip, not from an installer; and I think it can't change its config files being a child of that folder without being run as administrator - but I could be dead wrong).

One fellow apparently solved the issue via complete uninstall and reinstall of all java/eclipse related components: http://p2p.wrox.com/book-beginning-android-application-development/87299-override-errors-despite-1-6-a.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!