'Another Maven "Source option 6 is no longer supported. Use 7 or later."

I see lots of answers to this question but they don't work for me. I installed Visual Studio Code, latest version of Java and Maven on my PC and I was able to successfully build my application with Maven on the PC. I then went through the same steps on my Mac and I get this error.

Fresh versions of Macos, Visual Studio Code, Maven and Java. Like all the others have said, I added these lines to the properties section of my pom.xml file:

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

Still get the same error. Here is the relevant output from the mvn build:

alberts-mbp:com.versabuilt.rushmore.process albertyoungwerth$ mvn package
[INFO] Scanning for projects...
[INFO] 
[INFO] ---------< com.versabuilt.rushmore.process:VersaBuiltProcess >----------
[INFO] Building VersaBuilt Process 0.2.18
[INFO] -------------------------------[ bundle ]-------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ VersaBuiltProcess ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 5 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ VersaBuiltProcess ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 10 source files to /Users/albertyoungwerth/rushmore/com.versabuilt.rushmore.process/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Source option 6 is no longer supported. Use 7 or later.
[ERROR] Target option 6 is no longer supported. Use 7 or later.
[INFO] 2 errors

I have also restarted Visual Studio Code to no avail.



Solution 1:[1]

The last build system I used was called make, so it's been a while since I debugged a build process. I don't remember make dumping 62Kb of debug output either...

Anywho, searching for the keyword "source" (clue being that was one of the tags I was supposed to add) got me to this in the maven debug output:

[DEBUG] (f) source = 1.6

Ahaaa! the source compiler version had not changed like I asked it to with the edit in my original question! I'll bet the maven folks changed the location of the xml tag! Sure enough, searching for 1.6 in the pom.xml file I find this:

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

I changed the source and target tag values to 1.8 and it worked! I also tried deleting the source and target tags in the build plugins scope and left in the maven.compiler.source/target values set to 1.8 and that also worked.

So moral of the story, be careful of extra source or target tags in your pom.xml file!

Solution 2:[2]

Actually, I too faced the above error message, after adding this to property file, Error got resolved. :)

property need to be added in pom.xml

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

Solution 3:[3]

I corrected this problem by matching the jdk between my IDE and the pom.xml file.

Solution 4:[4]

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

Solution 5:[5]

Sometimes changing from Kotlin to java or inverted.

You can also change or java version to a higher one.

At least that worked for me.

Solution 6:[6]

Changing maven compiler version in pom file solved my issue. <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Al Youngwerth
Solution 2 TT.
Solution 3 ViejoAprendiz
Solution 4 KIRAN
Solution 5 freisi jorge
Solution 6 Maknaka