The method must override a superclass method

2020-03-26 06:25发布

Recently I updated my computer to Ubuntu 11.10 64-bits. I have a problem when importing my projects, it gives me an error

"The method onView() must override a superclass method".

I read in some other posts that the error should be the use of java 1.5, but Ubuntu 11.10 comes with open-6-jdk.

any ideas of a solution?

2条回答
再贱就再见
2楼-- · 2020-03-26 07:04

It sounds like the JDK compliance level of your project is set to 1.5. (The version of Java installed on the machine only determines how high you can set the compliance level.) You can check this in Eclipse by opening the project properties (right click on the project name, then select "Properties") and selecting "Java Compiler" on the left.

In Java 1.6, the @Override annotation can (and should) be used on methods that are defined in implemented interfaces. Java 1.5 did not allow this.

查看更多
不美不萌又怎样
3楼-- · 2020-03-26 07:11

Maybe you have multiple java virtual machines on your machine. Please type

$ ls /usr/lib/jvm

Do you see multiple entries there?

If yes, start Eclipse and go to Help->About Eclipse Platform->Configuration Details, and look for the property java.version (for me it is 1.7.0_03-icedtea).

If it is the wrong one you can go to Window->Preferences->Java->Installed JREs you can then change it to the one you like.

查看更多
登录 后发表回答