javac: invalid target release: 1.8

前端 未结 15 763
死守一世寂寞
死守一世寂寞 2021-01-30 12:22

I recently downloaded JDK 1.8.0.0_06 that comes bundled with NetBeans. I then got to find out that my JavaFx project, that I have been developing in Java 1.7 won\'t compile in J

相关标签:
15条回答
  • 2021-01-30 12:44

    Maven setting:

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    
    0 讨论(0)
  • 2021-01-30 12:44

    Alternatively, I checked the pom.xml and changed

    <java.version>1.8</java.version>
    

    to

    <java.version>1.7</java.version>
    
    0 讨论(0)
  • 2021-01-30 12:45

    None of the previous solutions worked for me.

    I solved it by editing .idea/compiler.xml There were "extra" (1) and (2) copies of the bad module with different targets. I deleted the extraneous entried and changed the targets in the section to 1.8 and it worked.

    0 讨论(0)
  • 2021-01-30 12:46

    Installing a newer release of IDEA Community (2018.3 instead of 2017.x) was solved my issue with same error but java version:11. Reimport hadn't worked for me. But it worth a try.

    0 讨论(0)
  • 2021-01-30 12:48

    For IntelliJ14 you may have to change the bytecode version w.r.t. the JDK you are using (in the global settings):

    enter image description here

    0 讨论(0)
  • 2021-01-30 12:50

    If this error occurs when running a Gradle (or Maven) task, you need to modify that build tool configuration to point to your installation of Java JDK 1.8 following this route:

    File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle

    There you check the Linked Gradle project is the one you are working on and select the Gradle JVM (You missed this when you imported the gradle project into IntelliJ)

    Remember when importing a Gradle (or Maven) project to set the target JVM correctly here:

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