IntelliJ IDEA 13 uses Java 1.5 despite setting to 1.7

后端 未结 13 860
我在风中等你
我在风中等你 2020-12-04 07:40

Despite specifying JDK 1.7 in all project settings (including in File -> Project Structure -> Project :: Project SDK), the following error is produced by

相关标签:
13条回答
  • 2020-12-04 08:24

    I managed to fix this by changing settings for new projects:

    1. File -> New Projects Settings -> Settings for New Projects -> Java Compiler -> Set the version

    2. File -> New Projects Settings -> Structure for New Projects -> Project -> Set Project SDK + set language level

    3. Remove the projects

    4. Import the projects

    0 讨论(0)
  • 2020-12-04 08:28

    In IntelliJ Community Edition 2019.02, Changing the following settings worked for me

    1. Update File->Project structure->Project Settings->Project->Project Language level to Java 11 (update to the java version that you wish to use in your project) using drop down.

    2. Update File->Project structure->Project Settings->Modules->Language level

    3. Update File->Settings->Build,Execution,Deployment -> Compiler -> Java Compiler-> Project ByteCode Version to java 11.

    4. Update Target version for all the entries under File->Settings->Build,Execution,Deployment -> Compiler -> Java Compiler-> Per module Byte Code Version.

    0 讨论(0)
  • 2020-12-04 08:30

    In your command line(Unix terminal) Go to your project root folder, and do this

    find . -type f -name '*.iml' -exec sed -i '' s/JDK_1_5/JDK_1_8/g {} +
    

    This will change the language level property in all your project .iml files from java 1.5 to java 1.8.

    0 讨论(0)
  • 2020-12-04 08:30

    I had the following property working for me in IntelliJ 2017

      <properties>
            <java.version>1.8</java.version>       
      </properties>
    
    0 讨论(0)
  • 2020-12-04 08:31

    Please check your project/module language levels (Project Structure | Project; Project Structure | Modules | module-name | Sources). You might also want to take a look at Settings | Compiler | Java Compiler | Per-module bytecode version.

    Set also this:

    File -> Project Structure -> Modules :: Sources (next to Paths and Dependencies) and that has a "Language level" option which also needs to be set correctly.

    0 讨论(0)
  • 2020-12-04 08:32

    [For IntelliJ IDEA 2016.2]

    I would like to expand upon part of Peter Gromov's answer with an up-to-date screenshot. Specifically this particular part:

    You might also want to take a look at Settings | Compiler | Java Compiler | Per-module bytecode version.

    I believe that (at least in 2016.2): checking out different commits in git resets these to 1.5.

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