Doro Doro - 1 year ago 210
Java Question

Eclipse Maven and Java 8 problems

I moved from simple web app to maven web app and with Eclipse Neon I encountered a frustrating problem: after I add in pom.xml the specification to use Java 8 or 7, it doesn't work.

To verify if it works I write a simple class where I use a try(expression) declaration.

What should I have to do to use Java 8 in maven (I have installed and it works in normal web app)?

The code of pom.xml is this:

<project xmlns="" xmlns:xsi=""







Answer Source

First, your JAVA_HOME must point to a JDK 8.
Else if is not the case, you must specify a JDK 1.8 as source and target in the compiler configuration of your pom.xml in this way :


Then, in eclipse, you must check in Preferences two things :

  • `Java->Installed JREs has a 1.8 JRE installed.

  • Java->Compileruses the JDK compliance level to 1.8.

You could check them as default if you want to use the 1.8 for any new created projects in your Eclipse.

At last, in the properties of your project, go to Java Build Path and in the Libraries tab. You must check that the JRE System Library uses Java 1.8. If it is not the case, remplace it with the 1.8 version.
When it is done, always in the properties of your project, go to Java Compiler and check that you use JDK compliance with Java 1.8.

It should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download