Error:(185, 13) java: try-with-resources is not supported in -source 1.5 (use -source 7 or higher to enable try-with-resources)

Ayeshmantha Perera :

In intelij maven compiling in Java SDK 1.8 but showing automatically changes to Java SDK 1.5 and shows this error

Dang Nguyen :

On your pom.xml file should have this, it specified the maven compiler to 1.8

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

Or

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=76565&siteId=1