Monday, March 23, 2015

Eclipse Dynamic Web Project complains about wrong Java version

I was having lots of Maven + Eclipse problems.

First, I was getting errors saying "java.lang.Object" was not found.  I examined by project build path and noticed that there was nothing. I added a Library, made it a Java JRE System Library and saw those errors be replaced by hundreds of other errors about missing objects.

Came to realize that I was missing my Maven dependencies in my build page.  A simple Maven->Update Project correct these missing dependencies.  Right click the project, then select Maven->Update Project.

Expecting all my problems to be resolved, I was greeted by more obscure errors:

Eclipse dynamic web module 3.0 requires java 1.6 or newer

After much trial and error I found the solution.  I updated my POM file to have the following content:


onematch
   
       
       org.apache.maven.plugins
       maven-compiler-plugin
       3.1
       
           1.7
           1.7
       
   
   

This apparently reminds Eclipse that, yes I really am using Java 1.7, and allows the DWP to be configured without error.  Yay.