Search code examples
javamavenintellij-ideamaven-3

Intelij Maven : error: Source option 6 is no longer supported. Use 7 or later. Is there anymore solutions?


I'm trying to install dependendies using mvn install but I got thiss error :

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.299 s
[INFO] Finished at: 2021-04-07T23:29:40+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project words-api: Compilation failure: Compilation failure:
[ERROR] error: Source option 6 is no longer supported. Use 7 or later.
[ERROR] error: Target option 6 is no longer supported. Use 7 or later.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
'cmd' is not recognized as an internal or external command,
operable program or batch file.

I tried to find solution on stackoverflow but for now I still get same error

What I've tried :

  1. Changing level language 2.Adding properties to pom.xml file

Other solution that I've found involves other type of IDE

Here is my pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>untitled1</artifactId>
    <version>1.0-SNAPSHOT</version>

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

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

I'm new to Maven and if you know any solutions tha I haven't tried please comment down below. I will be thankfull for your answers

Edit: I'm using apache.maven.3.8.1


Solution

  • Install Java 1.8 (JDK) and configure JAVA_HOME environment variable to point to the installation home of this Java version. You may need to logout/login or reboot for the environment variable change to have effect.

    Maven will use it for compilation and will be able to target 1.6 version.

    Java 11+ versions no longer support 1.6 target.

    In IntelliJ IDEA it can be controlled here:

    • Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Importing | JDK for importer
    • Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Runner | JRE