Error:java: javacTask: source release 8 requires target release 1.8

Using IntelliJ IDE can't compile any projects. Screenshots of settings below:

Used JDK:

Project SDK and Language level:

http://gyazo.com/55a5fc9f7f2bb721a04780ce9d74eeab

Language Level:

Anybody have any ideas?


  • File > Settings > Build, Execution, Deployment > Compiler > Java Compiler
  • Change Target bytecode version to 1.8 of the module that you are working for.
  • If you are using Maven

    Add the compiler plugin to pom.xml under the top-level project node:

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

    (Hoisted from the comments.)

    Note: If you don't mind reimporting your project, then the only thing you really need to do is change the pom and reimport the project, then IntelliJ will pick up the correct settings and you don't have to manually change them.


    You need to go to Settings and set under the Java compiler the following: 在这里输入图像描述

    also check the Project Settings


    This looks like the kind of error that Maven generates when you don't have the compiler plugin configured correctly. Here's an example of a Java 8 compiler config.

    <project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    
    <!-- ... -->
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.5.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    
    <!-- ... -->
    
    </project>
    
    链接地址: http://www.djcxy.com/p/66300.html

    上一篇: Java AES解密:最后的随机字符和消息

    下一篇: 错误:java:javacTask:源版本8需要目标版本1.8