views:

56

answers:

1

I imported a Maven project and it used Java 1.5 even though I have 1.6 configured as my Eclipse default (Preferences->Java->Installed JREs). When I changed the Maven project to use the 1.6 JRE it still had the build errors left over from when the project was using Java 1.5 (I described these build errors earlier in this question.)

I'm going to delete the project and try again but I want to make sure this time that it uses Java 1.6 from the start to see if this eliminates the build problems.

How do I make sure the project uses Java 1.6 when I import it?

+3  A: 

The m2eclipse plugin doesn't use Eclipse defaults, the m2eclipse plugin derives the settings from the POM. So if you want a Maven project to be configured to use Java 1.6 settings when imported under Eclipse, configure the maven-compiler-plugin appropriately, as I already suggested:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>2.1</version>
  <configuration>
    <source>1.6</source>
    <target>1.6</target>
  </configuration>
</plugin>

If your project is already imported, update the project configuration (right-click on the project then Maven V Update Project Configuration).

Pascal Thivent
Exactly. Won't fix the compile errors though.
Raoul Duke
Yes! That worked! Thanks!
Chris Collins
@Raoul YES it will! I explained the problem in my other answer, using Java 6 does fix the compilation errors. And I actually tested this by importing the project because of you insisting it doesn't solve the problem :)
Pascal Thivent
Please don't shout. That's just rude. It did work after deleting and re-importing the project. But not otherwise.
Raoul Duke
@Raoul It work without reimporting the project if you **Update Project Configuration** as I wrote. I did test this 3 times and it just works on my machine.
Pascal Thivent
I sure did. How would you know what I did or not did. That's pretty presumptuous.
Raoul Duke
Changing the compiler just works like I described and fixes the compilation errors. So yes I'm presumptuous, yes I'm opinionated, yes I have strong opinions, especially when I know that what I'm saying is 100% correct and when people are posting comments denying that, I have no problem admitting it.
Pascal Thivent