Maven Project – statement not supported in -source 1.5

Recently, I was working in a project and I coded a multi-catch statement because…you know…they’re cool.  Multi-catches were introduced in Java 1.7 and are not therefore supported with a compiler below 1.7.  Duh-doy!  But I’ve got it covered, right?  My Eclipse IDE is configured to use a 1.8 JDK.  My project is configured to compile with 1.8.  So why am I getting this message?

multi-catch statement is not supported in -source 1.5
(use -source 7 or higher to enable multi-catch statement)

I’ve been using maven with eclipse for 4 years and I’ve never run into this problem because a certain bit of config was always there and I didn’t know it. I found this statement at

Also note that at present the default source setting is 1.5 and the default target setting is 1.5, independently of the JDK you run Maven with. If you want to change these defaults, you should set source and target as described in Setting the -source and -target of the Java Compiler.

This is how independent Maven is.  It doesn’t care a lick about your IDE configuration or your local JDK.  If you do not tell it to compile at a particular version, it will run by default at 1.5.  If you’re having this problem, the solution is very simple.  Add the following text to the plugins tag of  your project pom.xml.










Now you can multi-catch, lambda, and stream with the cool kids!

Thanks for reading!  If you would like to see what else I’m up to, check out Whiff

One comment

  1. You can also resolve this problem by using below steps for Eclips user and can be work for IntelliJ as well-

    Right click on the project and select Buid Path then Configure Build Path..
    Select Project Facets under Maven.
    Then select Java version as 1.8 and apply ok.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s