Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 845
Al Youngwerth Avatar asked May 18 '20 01:05

Al Youngwerth


People also ask

What to do when Maven error 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.

Is source option 6 still supported in Java?

java - Another Maven "Source option 6 is no longer supported. Use 7 or later." - Stack Overflow 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.

How to fix [error] target option 5 is no longer supported?

Use 7 or later. [ERROR] Target option 5 is no longer supported. Use 7 or later. The fix for the problem is to use the latest Java environment for the project that is above JDK 7 or Later. Identify the JDK version installed on your machine or the version the IDE workspace uses.

How to enable full debug logging in Maven?

[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.


4 Answers

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!

like image 166
Al Youngwerth Avatar answered Oct 16 '22 01:10

Al Youngwerth


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>
like image 35
Gomathy M Avatar answered Oct 16 '22 00:10

Gomathy M


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

like image 43
ViejoAprendiz Avatar answered Oct 16 '22 00:10

ViejoAprendiz


<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.7</source>
        <target>1.7</target>
    </configuration>
</plugin>
like image 20
KIRAN Avatar answered Oct 16 '22 01:10

KIRAN