3

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?

3
  • Do you have a problem understanding the error message, or having problems configuring your JDK / Eclipse properly?
    – aioobe
    Commented Mar 27, 2012 at 14:17
  • is a strange problem with the jdk, as long as I had everything working before updating my computer Commented Mar 27, 2012 at 14:20
  • In Eclipse, you can still decide to choose a Java Runtime Environment different of the one installed. In Java 5, the @Override was not allowed on method implementing interface methods while in Java 6 it is strongly encouraged. If you happened to configure your project to a Java 5 environment, you could get this kind of error Commented Mar 27, 2012 at 14:21

3 Answers 3

13

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
  • @PedroTeran - Did you check the workspace properties or the project properties? They can be different.
    – Ted Hopp
    Commented Mar 27, 2012 at 14:21
  • I have ckecked the workspace before, the project properties was on 1.5, I forgot to check there, and there is the problem, thanks Commented Mar 27, 2012 at 14:31
  • Thanks. I just be reminded of it when encountering this headache error.
    – bnguyen82
    Commented Jun 22, 2012 at 11:39
1

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.

1
  • well yes I have open-6-jdk and open-7-jdk, but on help there is a java.version=1.6.0_23 Commented Mar 27, 2012 at 14:27
0

It's 2020 -

Project>Right Click>Java Compiler>Compiler Compliance Level> Change this to 1.8 [or latest level] enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.