mvn compile throws errors
Closed this issue Β· 34 comments
Hello,
I'm working on this guide, but when I run mvn compile
I get the following error:
[ERROR] Source option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
I'm on OS X. mvn -v
shows:
Maven home: /Users/matthuntington/Desktop/apache-maven-3.5.0
Java version: 9, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"
echo $JAVA_HOME
shows:
/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
echo $PATH
shows:
/Users/matthuntington/Desktop/apache-maven-3.5.0/bin/:/Users/matthuntington/.rbenv/bin:/Users/matthuntington/.rbenv/shims:/Users/matthuntington/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
any suggestions? Thanks!
Solution: I added
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
inside the project tag in pom.xml
Can you explain the reason of the error? I also get the same error.
Why does your solution solve the problem?
Thanks.
I think the latest version of maven doesnβt support 1.5 anymore. You have to explicitly tell it which version to compile to. Not entirely sure, though.
mahuntington great solution . Just add in pom
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
and it will compile
worked for me.
thanks
@strzelaczinho worked, thank you for an easy solution
Worked for me. thanks, Matt Huntington for an easy solution.
@mahuntington thanks it works for me.
A lot of things to think for a person who is beginning to use maven.
Thank you @mahuntington .
Worked like a charm. The error message that i got though is updated in 2018 :)
Source option 5 is no longer supported. Use 6 or later.
I wonder why someone doesn't just make it switch to 1.6 on it's own when 1.5 was hard wired into it.
Use JavaServlet 3.0-alpha-1
https://mvnrepository.com/artifact/javax.servlet/servlet-api/3.0-alpha-1
<!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>provided</scope>
</dependency>
has to be added after the name tag
Many thanks @mahuntington !!!
Solution from @mahuntington resolved it.
One thing everyone missed to explain for the newbies:
When the error states that "version 5 or 1.5" isn't supported, it's saying that Maven is trying to compile the java code using the JDK (java developer kit) version 1.5, ans it's not supported.
Thanks. Yeah, I'm glad I read on to see your comment. The error message makes a lot more sense now. I thought version 5 or 1.5 had something to do with Maven. I didn't realize it was talking about which version of Java the project was being compiled to.
//
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
//
Worked for me!
Worked like a charm. The error message that i got though is updated in 2018 :)
Source option 5 is no longer supported. Use 6 or later.
I wonder why someone doesn't just make it switch to 1.6 on it's own when 1.5 was hard wired into it.
Because this would change the behaviour silently which would be less obvious a problem.
worked for me. Thanks for the solution.
I'm new to maven, but am I missing something, or is this solution to modify each individual maven project POM.XML file?
Please tell me that there is there somewhere a central XML file that we're editing to solve this problem for all projects going forward?
Hello, I've got the same error and the solution worked.
Thank you very much.
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
I had a similar problem:
source option 6 is no longer supported use 7 or later
target option 6 is no longer supported use 7 or later
this snippet solved it for me
<properties> <maven.compiler.source>1.8</maven.compiler.source <maven.compiler.target>1.8</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>
add it in the pom.xml, properties section
Ctrl+S and voila!
It's working for me too, thank you
<maven.compiler.source>6</maven.compiler.source>
<maven.compiler.target>6</maven.compiler.target>
4.0.0
<groupId>com.list</groupId>
<artifactId>toDoList</artifactId>
<version>1.0-SNAPSHOT</version>
My project code looks like this and I am still getting:
Error:java: Source option 5 is no longer supported. Use 6 or later. (earlier someone said option 5 meant option 1.5)
Can you explain the reason of the error? I also get the same error.
Why does your solution solve the problem?
Thanks.
The reason for the error: maven compiler is a plugin inside the maven system. In the compile life cycle phase, maven takes the java version as configured in maven compiler plugin in the pom. When we have not specified the compiler plugin in the pom it takes the default compiler plugin which comes with maven versions. (eg: maven 2 comes with compiler version 1.4) If we want to use the latest java version at compile time need to provide it as follows
1.8 1.8Use JavaServlet 3.0-alpha-1
https://mvnrepository.com/artifact/javax.servlet/servlet-api/3.0-alpha-1<!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>3.0-alpha-1</version> <scope>provided</scope> </dependency>
Worked for "Source option 5 is no longer supported. Use 6 or later" when using InteliJ for Cucumber test automation
I had this problem and didn't need to add anything to pom.xml. Just make sure that IDE compiler is set to appropriate version. Also check in project preferences that language level and SDK are set to appropriate version.
Solution: I added
<properties> <maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.target>1.6</maven.compiler.target> </properties>
inside the project tag in pom.xml
@mahuntington
Works for me.
Thanks a lot!
@mahuntington Thanks for solution
Solution: I added
<properties> <maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.target>1.6</maven.compiler.target> </properties>
inside the project tag in pom.xml
Worked!
Thanks