views:

220

answers:

2
+1  Q: 

Java auto boxing

I switched a project I'm working on over to maven and suddenly auto boxing seems to have broken. My IDE (NetBeans) complains on lines such as the one below with the error "Incompatible types"

Integer order = 4;
+3  A: 

Check to ensure you are still compiling with a post-1.5 JDK, and that your compatibility settings are not tuned down below 1.5 either.

Jared
I'm new to Maven, but I'm assuming that would be declared somewhere in the POM. There are no compatibility options set, and a mvn -v shows the Java version at 1.6.0_15.
sensae
After looking further, it seems maven compiled with Java 1.3 by default. I had to modify the POM to explicitly specify a build target of 1.6. Thanks.
sensae
NetBeans (in all likelihood) is not calling Maven to get compiler error listings - it's using its internal compiler. You need to pay attention to whether the compiler error output is coming from Maven or NetBeans - they're different.
Jared
+2  A: 

The internal compiler (used for editor hints) will follow the source settings in the POM, to match the behavior of a full Maven build. Maven currently defaults to 1.3 as a source level: http://jira.codehaus.org/browse/MCOMPILER-80 You can change the source level by editing the POM, or (more easily) using the NetBeans project properties dialog.

Jesse Glick