IntelliJ IDEA Tip: source release 1.6 requires target release 1.6

If you are an IntelliJ IDEA user and you are using Maven in your project, chances are you may some day run into this incredibly cryptic and confusing message:

Error: javac: source release 1.6 requires target release 1.6

Googling it digs up a few approaches to solving the problem as well as some IntelliJ IDEA bug reports where people describe needing to re-create their projects to get rid of it.

Fortunately for me, the fix was exactly what was outlined by Daniel Höpfl here. Daniel pointed out that in his install of IntelliJ IDEA, under the File > Settings > Compiler > Java Compiler preference screen, for some reason “-target 1.4” had been set as an additional compiler parameter. Turns out, that is exactly what happened to me too:

All I had to do was remove that bogus setting and everything worked again.

The odd thing is that I’ve never messed with these settings before, the one thing I did do was configure the “maven-compiler-plugin” Maven plugin as well as the “maven-dependency-plugin” for my project — it is possible there is a synchronization bug in IntelliJ that causes that value to populate when trying to parse those settings from your project’s pom.xml, but that is just a guess.

Happy coding!

Tags: , , , , , , , , ,

About Riyad Kalla

Software development, video games, writing, reading and anything shiny. I ultimately just want to provide a resource that helps people and if I can't do that, then at least make them laugh.

, , , , , , , , ,

35 Responses to “IntelliJ IDEA Tip: source release 1.6 requires target release 1.6”

  1. GH August 6, 2010 at 6:39 am #

    Thank you! A very succinct and clear explanation that had me back up and running in no time. You just saved me a lot of frustration I’m sure as like you say, this error message is pretty vague.

    • Riyad Kalla August 6, 2010 at 9:42 am #

      GH, glad I could help. I was at wits end when I hit this, so I knew I had to blog it incase anyone else hit it ;)

  2. Alima August 10, 2010 at 12:56 am #

    Thank you for help

    • Riyad Kalla August 10, 2010 at 6:46 am #

      Alima, you are most welcome. Hope it helped save you some stress ;)

  3. Gary August 23, 2010 at 2:19 am #

    Good call. I’ve just come across this as well and thanks to your article had it resolved in a jiffy. Thanks!

  4. Riyad Kalla August 23, 2010 at 6:00 am #

    Did any of you set this -source argument or are all of you finding it magically inside your IJ setups and needing to clear it?

    I’m wondering if there is a bug in IJ that I need to report, just want to figure out the commonality before submitting.

    • Gary August 23, 2010 at 7:10 am #

      It just happened magically for me. I certainly would not have set target=1.5 manually – I don’t use it anymore for one thing.

      • Riyad Kalla August 23, 2010 at 7:43 am #

        Gary, did you set custom compiler plugins values for Maven in your POM? That is what I did before this problem popped up. When just working with plain Maven and dependencies, I never noticed it. As soon as I started messing with how the packaging was done (to include my dependent JARs) this issue arose.

        • Gary August 23, 2010 at 12:52 pm #

          Yeah, I always feel the need to specifically state which version of Java I’m targeting in the POM. Along with pretty much everything else. So it would appear that Intellij has picked up the Maven settings and configured itself against them but has not remained in synch.

  5. Elena August 30, 2010 at 12:35 pm #

    Really appreciate your help. Extremely useful post.

  6. Ryan P August 30, 2010 at 1:10 pm #

    Thanks,
    I ran into this same issue today and this fixed it perfectly!

  7. Gus October 22, 2010 at 1:25 pm #

    Thanks! This saved me at least a day of digging around in settings.

  8. Mircea October 25, 2010 at 3:43 am #

    You’re the man, you just made my day :) I was struggling with this stupid error message for hours now. THANKS A LOT.

  9. Skjalg October 31, 2010 at 1:22 pm #

    Thanks for the post. You made my day! I came across the problem when I used maven with the settiing:

    org.apache.maven.plugins
    maven-compiler-plugin

    1.6
    1.6

    where I previously had used 1.5: Intellij had “-target 1.5″ in the settings, which I had not set…

  10. Ingo February 22, 2011 at 12:08 pm #

    Thank you for this post – I just compiled apache-tika with maven2 on IntelliJ-Idea-10 and suddenly I found this strange error message.

  11. Simon Woodman February 24, 2011 at 2:32 am #

    Thank you so much – saved me hours of pain!

  12. Cristian June 11, 2011 at 11:26 pm #

    Thanks buddy… this solved the problem.

  13. Chris July 6, 2011 at 7:52 am #

    Thank you – this article was very helpful!!!!

  14. Ben July 28, 2011 at 5:36 am #

    Yes helped me too – and no, I didn’t set this property myself, was automagic as you point out. Thanks!

  15. Daniel August 30, 2011 at 1:34 am #

    Thanks a lot man! You saved me lots of time hunting this nasty little bug down…
    Great blog!

    • Riyad Kalla September 3, 2011 at 9:59 am #

      Glad to hear it, this one had me stumped when I ran into it.

  16. Bharat September 6, 2011 at 1:27 am #

    Thanks for this. Within seconds have got further.

  17. John Cameron October 7, 2011 at 4:12 pm #

    Bless you and all generations of your offspring forever!

    I would have spent countless hours locating this crazy bug!

  18. Aleksey Vitebskiy November 3, 2011 at 11:34 am #

    Thanks a lot! This was probably the fastest I ever got an actual answer while Googling an error message!

    • Riyad Kalla November 3, 2011 at 11:11 pm #

      Aleksey, really glad I could help. That is exactly how I wanted people to find this (and not have to tear all their hair out). Happy coding!

  19. Sam November 12, 2011 at 3:55 pm #

    Fantastic! This was the final, missing step in order for me to get Idea working on Ubuntu using Open JDK. The first of which was installing JDK 7, as it wouldn’t work with v6 for what ever reason.

    Thanks again!

    • Riyad Kalla November 13, 2011 at 3:16 pm #

      Most welcome Sam, glad to hear you got everything configured and working.

  20. Gorka Siverio April 16, 2012 at 9:47 am #

    thx for the tip! A quick and clear response.

    One day I was compiling ok, and the next that error showed up. But no one had touched my IDEA settings. Could it had loaded that info from some change in a pom.xml?

  21. Joshua Kamau July 23, 2012 at 12:03 pm #

    You are the man! … This saved my day.

    Thanks.
    Josh

  22. Peter January 16, 2013 at 3:28 am #

    Yay, cool…. thanks for posting this. Weird and extremely unuseful error message indeed :(

  23. Siddharth October 31, 2013 at 3:44 am #

    What can i do in Spring Tool Suit editor and Grails framework for the following error..??
    javac: target release 1.5 conflicts with default source release 1.7

    • Siddharth October 31, 2013 at 5:01 am #

      I solve this by my self…..
      In order to work, It was needed to install the plugins:

      cxf

      cxf-client

      Installing these two plugins resolved the problem.

Leave a Reply


8 − = 1