Error:java: invalid source release: 8 in Intellij. What does it mean?

前端 未结 16 892
旧时难觅i
旧时难觅i 2020-11-27 08:55

Im trying to compile some code in I\'m using Intellij Ultimate 13.1.4, but I get the following error and I have no idea what it means:

Information:Using java         


        
相关标签:
16条回答
  • 2020-11-27 09:47

    Check your pom.xml first (if you have one)
    Check your module's JDK dependancy. Make sure that it is 1.8
    To do this,go to Project Structure -> SDK's
    Add the path to where you have stored 1.8 (jdk1.8.0_45.jdk in my case)
    Apply the changes
    Now, go to Project Structure ->Modules
    Change the Module SDK to 1.8
    Apply the changes

    Voila! You're done

    0 讨论(0)
  • 2020-11-27 09:47

    I add one more path unmentioned in this answer https://stackoverflow.com/a/26009627/4609353

    but very important is Edit Configurations

    0 讨论(0)
  • 2020-11-27 09:49

    I tried out all the steps mentioned in here https://stackoverflow.com/a/26009627/2058104, but the 4th point has now changed. You need to go to Preferences -> Build, Execution, Deployment -> Compiler -> Java Compiler

    In there, as shown in below figure, you need to change the "Target bytecode version". Although, I changed it to 8 (since I needed to downgrade to Java 8), it was giving the same error, over and over. Therefore, try to remove the existing entry (in this table) and add it again. This worked for me.

    On the other hand, clean the project and try to run again.

    0 讨论(0)
  • 2020-11-27 09:51

    For Gradle users having this issues, if nothing above helps this is what solved my problem - apply this declarations in your build.gradle files:

    targetCompatibility = 1.6 //or 1.7;1.8 and so on
    sourceCompatibility = 1.6 //or 1.7;1.8 and so on
    

    Problem solved!

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