use -source 7 or higher

后端 未结 7 1447
既然无缘
既然无缘 2020-12-28 12:15

While trying to build a project using intelliJ Ultimate 12 I am getting these errors

use -source or higher to enable diamond operator
use -source 7 or higher         


        
相关标签:
7条回答
  • 2020-12-28 12:57

    For IntelliJ IDEA Community 2018.2:

    • In the project tool window, right-click on the project name to get to the Project Structure menu.
    • Set Language Level to whatever version you want, and rebuild project again.

    You can also use F4 as shortcut to get to the same menu.

    0 讨论(0)
  • 2020-12-28 12:59

    In addition to the accepted answer, you may also need to change the language level under Project Structure > Modules > Sources tab.

    I also needed to change the java compiler being used at the IDE level under IntelliJ IDEA > Preference > Compiler > Java Compiler to 1.7 from 1.6. The exact location of the setting will vary based on your OS and version of IntelliJ IDEA.

    0 讨论(0)
  • 2020-12-28 13:01

    I had the same problem and was struggling. Auto-import was true, re-import of project was not working and tried all possible options. But finally i found the solution.

    "Reimport All Maven Projects" did the trick for me.
    You can find the option on the Maven Project tab.


    enter image description here

    0 讨论(0)
  • 2020-12-28 13:02

    the language level for a project is set in the project structure dialog: project structure dialog you want to make sure you set the language level to java 7, and the sdk accordingly

    0 讨论(0)
  • 2020-12-28 13:02

    If using Gradle as a build automation, set following settings in build.gradle and re-import your project:

    sourceCompatibility = 1.7

    targetCompatibility = 1.7

    0 讨论(0)
  • 2020-12-28 13:07

    None of the above worked for me.

    I had to explicitly add the following plugin statement to my pom.xml:

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

    (Well, IDEA made it for me when I clicked the red help lamp and selected "Set project Java level to 7", so maybe try that if this also doesn't work).

    0 讨论(0)
提交回复
热议问题