On 12/15/2010 15:02, [email protected] wrote: > Hi, Jörn, > > Do you know how to ensure that the java compatibility level? The note at the > bottom of > http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html<http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html:>says > that setting source/target is not enough, but I can't understand what > they mean with configure the compiler's boot classpath to match the target > JRE. Do we have to hard code the classpath?
When you consider compatibility, you need to consider byte code compatibility and library compatibility. Those are basically orthogonal issues. The library comes with the JDK you're using to compile the code, so to make sure that your source code is compatible with the 1.5 java libs, you must use a Java 1.5 JDK in Eclipse. The easiest way to do that is to make a 1.5 JDK your default JDK in preferences/ Java/Installed JREs. Do not fiddle with the individual projects' reference to the JRE System Library in the classpath, that way leads only to pain and grief. Only the byte code compatibility can be ensured with the compiler JDK compliance settings. To sum up, if you want your code to be compatible with Java 1.5, you must ensure 1.5 byte code compatibility *and* 1.5 library compatibility by compiling with a 1.5 JDK (not 1.6 or higher). Unfortunately, as far as I know, there is no setting either in Eclipse or maven that can ensure that you actually are using a 1.5 JDK and will throw an error if you don't. So this is up to the developer, and accidents happen all the time :-( --Thilo > > Thanks > William > > > On Wed, Dec 15, 2010 at 10:10 AM, Jörn Kottmann <[email protected]> wrote: > >> On 12/15/10 1:03 PM, [email protected] wrote: >> >>> Hi, >>> >>> When I try to load the project from Eclipse, some build errors appear >>> because the project is set to use Java 1.5, but the code use Java 1.6 API >>> String.isEmpty for example. >>> >>> It is OK to build using command line, but using M2Eclipse it fails to >>> build. >>> >>> Maybe I'm missing something. >>> >>> By the way, isn't it better to keep Java 1.5 compatibility? >>> >> >> Yes, that is a little embarrassing, it should have been found >> while making the 1.5.0 release. I think we should fix it now >> and ensure that the java compatibility level is enforced during >> our release process. >> >> Can you open a jira for it and fix the code ? >> >> Thanks, >> Jörn >> >
