Error:java: Compilation failed: internal java compiler error

created at 12-24-2021 views: 158

error

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.

reason

The main reason for this error is the jdk version problem. There are three reasons here, one is insufficient memory, the other is the compiled version does not match, and the other is that the jdk version of the current project does not support it.

Not enough storage

Use the shortcut key Ctrl+Alt+shift+S to open the jdk configuration of the project and increase the memory:

 increase the memory

View the project's jdk

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

sdk

Check whether these two places are consistent with the target jdk.

View the project's jdk

Click Modules in the figure above to view the corresponding jdk version:

modules

View java compiler version

java compiler version

When importing the java project, the probability of the problem here is more.

In response to this problem, reopening or modifying the contents of the pom file (maven project) is likely to cause the jdk version to change to 1.5 again. 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>
created at:12-24-2021
edited at: 12-24-2021: