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 maven.apache.org

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.

compiler-plugin

<plugin>

<artifactId>maven-compiler-plugin</artifactId>

<version>3.1</version>

<configuration>

<source>1.8</source>

<target>1.8</target>

</configuration>

</plugin

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