gs-maven: mvn compile throws errors
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!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 23
- Comments: 34 (1 by maintainers)
Commits related to this issue
- Quick fix for Java bug https://github.com/spring-guides/gs-maven/issues/21 — committed to sigopt/sigopt-examples by alexandraj777 6 years ago
- Specify source and target to avoid build error Related to spring-guides/gs-maven#21 — committed to soarez/qfs by soarez 6 years ago
- Specify source and target to avoid build error Related to spring-guides/gs-maven#21 — committed to soarez/qfs by soarez 6 years ago
- Specify Java version as 1.8 Pulling down a fresh copy of this repo and running the example command results in compilation errors about source option 5 and target option 1.5 no longer being supported.... — committed to mike-solomon/found-shield-example by mike-solomon 6 years ago
- mvn build issue some little workaround for mvn build issues, https://github.com/spring-guides/gs-maven/issues/21 — committed to rafche/check_temp by rafche 5 years ago
- mvn build issue some little workaround for mvn build issues, https://github.com/spring-guides/gs-maven/issues/21 Bugfix fixing bug, used wrong execution for destination OS ... — committed to rafche/check_temp by rafche 5 years ago
Solution: I added
inside the project tag in pom.xml
mahuntington great solution . Just add in pom
and it will compile
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.
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!
Use JavaServlet 3.0-alpha-1 https://mvnrepository.com/artifact/javax.servlet/servlet-api/3.0-alpha-1
A lot of things to think for a person who is beginning to use maven. Thank you @mahuntington .
@mahuntington Thanks for solution
@mahuntington Works for me. Thanks a lot!
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
<properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties>https://maven.apache.org/plugins/maven-compiler-plugin/
@mahuntington thanks it works for me.
Worked for me. thanks, Matt Huntington for an easy solution.
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.