Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mvn compile throws errors #21

Closed
mahuntington opened this issue Oct 15, 2017 · 31 comments

Comments

@mahuntington
Copy link

@mahuntington mahuntington commented Oct 15, 2017

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!

@mahuntington

This comment has been minimized.

Copy link
Author

@mahuntington mahuntington commented Oct 17, 2017

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

@grassit

This comment has been minimized.

Copy link

@grassit grassit commented Jan 8, 2018

Can you explain the reason of the error? I also get the same error.

Why does your solution solve the problem?

Thanks.

@mahuntington

This comment has been minimized.

Copy link
Author

@mahuntington mahuntington commented Jan 8, 2018

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.

@strzelaczinho

This comment has been minimized.

Copy link

@strzelaczinho strzelaczinho commented Feb 12, 2018

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

@vm137

This comment has been minimized.

Copy link

@vm137 vm137 commented Feb 16, 2018

worked for me.
thanks

alexandraj777 added a commit to sigopt/sigopt-examples that referenced this issue Feb 28, 2018
@bilalyldz

This comment has been minimized.

Copy link

@bilalyldz bilalyldz commented Mar 14, 2018

1.6 1.6 It is actually working but you have to be careful where to add it. You need to ad it inside the Properties without tags (open-close)
@gregturn

This comment has been minimized.

Copy link
Contributor

@gregturn gregturn commented Apr 4, 2018

Resolved via c2bf553

soarez added a commit to soarez/qfs that referenced this issue Apr 16, 2018
soarez added a commit to soarez/qfs that referenced this issue Apr 16, 2018
@YaponEran

This comment has been minimized.

Copy link

@YaponEran YaponEran commented May 15, 2018

@strzelaczinho worked, thank you for an easy solution

mikesol314 added a commit to mikesol314/found-shield-example that referenced this issue Jun 21, 2018
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. Some digging around
online led me to find this issue: spring-guides/gs-maven#21
where someone proposed a solution that fixed this issue.

Basically maven doesn't support 1.5 anymore and you have to
explicitly tell it which version to compile to.
@sravankumar4

This comment has been minimized.

Copy link

@sravankumar4 sravankumar4 commented Jul 7, 2018

Worked for me. thanks, Matt Huntington for an easy solution.

@amitbpal

This comment has been minimized.

Copy link

@amitbpal amitbpal commented Jul 9, 2018

@mahuntington thanks it works for me.

@juanmiguel431

This comment has been minimized.

Copy link

@juanmiguel431 juanmiguel431 commented Jul 18, 2018

A lot of things to think for a person who is beginning to use maven.
Thank you @mahuntington .

@nitishpandey

This comment has been minimized.

Copy link

@nitishpandey nitishpandey commented Jul 28, 2018

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.

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Aug 1, 2018

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>

@fastestonakinapass

This comment has been minimized.

Copy link

@fastestonakinapass fastestonakinapass commented Aug 2, 2018

has to be added after the name tag

@plao

This comment has been minimized.

Copy link

@plao plao commented Sep 8, 2018

Many thanks @mahuntington !!!

@lkamal

This comment has been minimized.

Copy link

@lkamal lkamal commented Oct 1, 2018

Solution from @mahuntington resolved it.

@ltlombardi

This comment has been minimized.

Copy link

@ltlombardi ltlombardi commented Oct 3, 2018

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.

@matthiasdenu

This comment has been minimized.

Copy link

@matthiasdenu matthiasdenu commented Oct 26, 2018

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.

@aliasgarbaldiwalagartner

This comment has been minimized.

Copy link

@aliasgarbaldiwalagartner aliasgarbaldiwalagartner commented Nov 9, 2018

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

Worked for me!

@philipwhiuk

This comment has been minimized.

Copy link

@philipwhiuk philipwhiuk commented Jan 8, 2019

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.

@jcortejoso jcortejoso mentioned this issue Jan 18, 2019
1 of 6 tasks complete
@bastibaumi

This comment has been minimized.

Copy link

@bastibaumi bastibaumi commented Feb 14, 2019

worked for me. Thanks for the solution.

@afincher

This comment has been minimized.

Copy link

@afincher afincher commented May 4, 2019

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?

@JaimeCosteira

This comment has been minimized.

Copy link

@JaimeCosteira JaimeCosteira commented May 8, 2019

Hello, I've got the same error and the solution worked.
Thank you very much.

@peterwillcn

This comment has been minimized.

Copy link

@peterwillcn peterwillcn commented Jun 29, 2019

<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>
rafche added a commit to rafche/check_temp that referenced this issue Jun 29, 2019
some little workaround for mvn build issues, spring-guides/gs-maven#21
rafche added a commit to rafche/check_temp that referenced this issue Jun 29, 2019
some little workaround for mvn build issues, spring-guides/gs-maven#21
Bugfix

fixing bug, used wrong execution for destination OS
...
@AhmadHamed

This comment has been minimized.

Copy link

@AhmadHamed AhmadHamed commented Jul 7, 2019

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!

@franka107

This comment has been minimized.

Copy link

@franka107 franka107 commented Sep 11, 2019

It's working for me too, thank you

@e-remington-lee

This comment has been minimized.

Copy link

@e-remington-lee e-remington-lee commented Sep 15, 2019



<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)

@manoripriyadarshani

This comment has been minimized.

Copy link

@manoripriyadarshani manoripriyadarshani commented Sep 24, 2019

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

https://maven.apache.org/plugins/maven-compiler-plugin/

@e-remington-lee

This comment has been minimized.

Copy link

@e-remington-lee e-remington-lee commented Sep 24, 2019

@manojdjayz

This comment has been minimized.

Copy link

@manojdjayz manojdjayz commented Nov 14, 2019

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>

Worked for "Source option 5 is no longer supported. Use 6 or later" when using InteliJ for Cucumber test automation

@wojtekDrozd

This comment has been minimized.

Copy link

@wojtekDrozd wojtekDrozd commented Nov 24, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.