@Override is not allowed when implementing interface method

JavaExtjsIntellij IdeaOverridingGxt

Java Problem Overview


I have the problem mentioned in the title. You could say that this thread duplicates another one: How do I turn off error validation for annotations in IntelliJ IDEA?

But the solution given there doesn't work. They say that I need to take the following action:

> In the Project Structure | Project dialog, change the Project language Level to 6.0 - @Override in interfaces.

However, the Project language Level is 6.0 at the moment, but I still see the error.

Vic, here is the window and there is no JVM version right under Language level (unfortunately I can't post images because I have 10 reputation)

Java Solutions


Solution 1 - Java

If your project has multiple modules, also check that every module uses language level 6 or above, or use the project's language level (see Project Settings > Modules > xxx > Language level).

You may need to reload your project once it is modified.

Solution 2 - Java

At your module/project, Right click to see context menu:

enter image description here

Choose Open Module Settings or press F4. In setting windows:

enter image description here
Set value for Choose Language level section.


You also should check Project language level by this way: press Ctrl+Alt+Shift+S

enter image description here

Solution 3 - Java

A simpler solution - inline

  1. Put the caret on the @Override word and move the caret on the left side until the red bulb icon will appear. Then click on it.

enter image description here

  1. Click on Set language level to 6 - Override in interfaces

enter image description here


The method above is an alternative to the following approach:

  1. Go to File > Project Structure... or press Ctrl+Alt+Shift+S

enter image description here

  1. Go to Project Settings > Modules > Sources > Language level and choose any level that is 6 or greater than 6.

enter image description here

Solution 4 - Java

If you are using maven, add maven compiler plugin to the project's pom.xml file.

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

This solved the issue for me.

Solution 5 - Java

There's also a language level for every module. Please check your module settings in the Project Structure.

Solution 6 - Java

I ran into this problem for the first time while using a multi module maven project. As other answers / IDE suggested, we need to set the language level.

Rather than changing the setting of IDE, to make the project IDE agnostic, I update the parent pom with below properties, which solved the issue.

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

Solution 7 - Java

In JIdea 2020.1.2 and above,

  1. Go to Project Structure [ Ctrl+Alt+Shift+S ]
  2. Select Modules sub section
  3. Select each module
  4. Under sources-section, check Language Level
  5. Change the Language Level as required

enter image description here

NOTE:

If you get below error after this change,

Error:java: Compilation failed: internal java compiler error

You have to change the target bytecode version as well.

  1. Go to Settings [ Ctrl+Alt+S ]
  2. Select Java Compiler
  3. Select module in the table
  4. Change the byte-code version to map what you selected in the previous step for language-level

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNikitin MikhailView Question on Stackoverflow
Solution 1 - JavaBastien JansenView Answer on Stackoverflow
Solution 2 - JavaJames GrahamView Answer on Stackoverflow
Solution 3 - JavaROMANIA_engineerView Answer on Stackoverflow
Solution 4 - Javanuwan.chamaraView Answer on Stackoverflow
Solution 5 - JavaPeter GromovView Answer on Stackoverflow
Solution 6 - JavasssView Answer on Stackoverflow
Solution 7 - JavaprimeView Answer on Stackoverflow