[Solved] Error:java: Compilation failed: internal java compiler error

Error phenomenon

When using idea to import a new project or upgrade idea or create a new project, the following exception message will appear:

Error:java: Compilation failed: internal java compiler error 

Cause of error

This error is mainly caused by the JDK version. There are two reasons: the compiled version does not match, and the current project JDK version does not support.

View the JDK of the project

File -> Project Structure-> Project Settings -> Project or use the shortcut Ctrl+Alt+shift+S to open the JDK configuration of the project:

Check whether these two points are consistent with the target JDK.

View the JDK of the project

Click modules in the figure above to view the corresponding JDK version:

View java compiler version

When importing Java projects, the probability of this problem is high.

To solve this problem, reopening or modifying the contents of the POM file (Maven project) is likely to cause the JDK version to change back to 1.5. If it is a maven project, you can specify JDK related information in the POM file:

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

Read More: