Ok, my bad, I didn't explain myself clearly… I meant, the byte code generated by the compiler is totally independent from the _kind_ of JVM that will be used to run it.
So a code compiled for 1.6 will run on a sun JDK as on a openJDK. Nevertheless, the code must be compiled for the right version or lesser. So if you have a 1.6 JVM, you need the code to be compiled for a 1.6 or 1.5 or 1.4… The JVMs are retro-compatibles (a 1.6 JVM can run a 1.5 byte code). Further more, java compiler are also retro-compatibles. It means that a compiler that can compile a 1.7 code can compile it as a 1.6 code. This is the difference between : <source>1.6</source> and <target>1.6</target> in the maven's pom.xml. So if you use <source>1.7</source> <target>1.5</target> You'll need a 1.7 JDK to compile it but only a 1.5 or higher JVM to run it. Obviously, the source version must be equals or higher than the target version, and if your code use 1.7 features, the source version must be (at least) 1.7 or the compiler will raise an error. Finally, as said James, if you want to industrialize your tests, you should use a dedicated tool as Jenkins (I don't know if continuum can do that). If you want, you can use profiles in Maven to switch easily the versions to use ( http://maven.apache.org/guides/introduction/introduction-to-profiles.html). 2012/6/13 Gilles Sadowski <gil...@harfang.homelinux.org> > On Wed, Jun 13, 2012 at 03:05:13PM +0200, Xavier Detant wrote: > > The byte code generated by the compiler is totally independent from the > JVM > > that will be used to run it. > > Totally independent? Compiling with 1.7 and running with 1.6 will raise > this > error: > Unsupported major.minor version 51.0 > > > So I think the point is not «How to compile > > using the right JDK?» but «How to run with using the right JVM?» Am I > > wrong? > > It is both: compiling _and_ running the tests. > > I should be able to do all combinations, i.e.: > 1. Compile with javac 1.6 and run with java 1.6 > 2. Compile with javac 1.7 and run with java 1.7 > 3. Compile with javac 1.6 and run with java 1.7 > (and similarly with s/6/5/) > > > If so, this can't be done at compile time, so it can't be done via > > maven, unless you use antrun maven's plugin to create a ant task to > launch > > your program. > > The point is to compile and then _run_ the unit tests, assuming that the > code conforms to the syntax of Java 5, Java 6, and Java 7, respectively. > > In particular, if some source code is Java 5, it should be compatible with > more recent versions of the Java language, thus be compilable with more > recent implementations of javac. > The ultimate goal is to check that the unit tests pass independently of the > javac and java versions. > > > Best regards, > Gilles > > > > > 2012/6/13 Gilles Sadowski <gil...@harfang.homelinux.org> > > > > > Hello. > > > > > > > > > > > With maven, you can configure the compiler to compile in the version > you > > > > want. > > > > > > > > Add this to the pom.xml and set the arguments as you which. > > > > > > > > <build> > > > > <pluginManagement> > > > > <plugin> > > > > <groupId>org.apache.maven.plugins</groupId> > > > > <artifactId>maven-compiler-plugin</artifactId> > > > > <version>2.4</version> > > > > <configuration> > > > > <encoding>UTF-8</encoding> > > > > <source>1.6</source> > > > > <target>1.6</target> > > > > <compilerArguments> > > > > <Xlint:-unchecked /> > > > > </compilerArguments> > > > > </configuration> > > > > </plugin> > > > > > > > > See http://maven.apache.org/plugins/maven-compiler-plugin/ for more > > > > informations. > > > > > > I had seen that, but that cannot be the whole story (unless there is > some > > > maven magic involved); indeed, how can maven differentiate > > > java-6-openjdk-amd64 > > > from > > > java-6-sun > > > (since both are Java 1.6)? > > > > > > I was thinking that there should be some environment variable(s) whose > > > setting would somehow activate the above configuration. > > > > > > > > > Regards, > > > Gilles > > > > > > > > > > > > > > > 2012/6/13 Gilles Sadowski <gil...@harfang.homelinux.org> > > > > > > > > > On Wed, Jun 13, 2012 at 12:48:31PM +0200, Jochen Wiedmann wrote: > > > > > > Yes, that switch is called PATH (environment variable). > > > > > > > > > > Do you mean that I should change the PATH variable just to build > > > Commons > > > > > Math? > > > > > I surely hope that there is a more flexible way. > > > > > > > > > > With "ant", all that's needed is to define JAVA_HOME (another > > > environment > > > > > variable, but specific to the task at hand). > > > > > > > > > > > On Wed, Jun 13, 2012 at 12:19 PM, Gilles Sadowski > > > > > > <gil...@harfang.homelinux.org> wrote: > > > > > > > Hello. > > > > > > > > > > > > > > Are there command-line switches that will select a specific > JDK? > > > > > > > I.e. I have several of them installed: > > > > > > > > > > > > > > $ ls -l /usr/lib/jvm > > > > > > > total 36 > > > > > > > lrwxrwxrwx 1 root root 24 Dec 17 11:04 default-java -> > > > > > java-1.6.0-openjdk-amd64 > > > > > > > lrwxrwxrwx 1 root root 18 Jan 5 18:27 java-1.5.0-gcj -> > > > > > java-1.5.0-gcj-4.6 > > > > > > > drwxr-xr-x 6 root root 4096 Jan 18 15:04 java-1.5.0-gcj-4.4 > > > > > > > drwxr-xr-x 6 root root 4096 Mar 7 17:33 java-1.5.0-gcj-4.6 > > > > > > > lrwxrwxrwx 1 root root 23 Aug 11 2010 java-1.5.0-sun -> > > > > > java-1.5.0-sun-1.5.0.22 > > > > > > > drwxr-xr-x 10 root root 4096 Aug 11 2010 > java-1.5.0-sun-1.5.0.22 > > > > > > > lrwxrwxrwx 1 root root 20 Dec 16 18:51 > java-1.6.0-openjdk-amd64 > > > -> > > > > > java-6-openjdk-amd64 > > > > > > > lrwxrwxrwx 1 root root 20 May 3 14:00 > java-1.7.0-openjdk-amd64 > > > -> > > > > > java-7-openjdk-amd64 > > > > > > > drwxr-xr-x 3 root root 4096 Jan 18 15:38 java-6-openjdk > > > > > > > drwxr-xr-x 7 root root 4096 Mar 7 17:29 java-6-openjdk-amd64 > > > > > > > drwxr-xr-x 3 root root 4096 Jan 18 15:38 java-6-openjdk-common > > > > > > > lrwxrwxrwx 1 root root 19 Jun 9 2011 java-6-sun -> > > > > > java-6-sun-1.6.0.26 > > > > > > > drwxr-xr-x 8 root root 4096 Jan 18 15:47 java-6-sun-1.6.0.26 > > > > > > > drwxr-xr-x 7 root root 4096 Jun 5 17:12 java-7-openjdk-amd64 > > > > > > > drwxr-xr-x 3 root root 4096 Jun 5 17:12 java-7-openjdk-common > > > > > > > lrwxrwxrwx 1 root root 12 Jan 5 18:27 java-gcj -> > java-gcj-4.6 > > > > > > > lrwxrwxrwx 1 root root 18 Apr 29 2010 java-gcj-4.4 -> > > > > > java-1.5.0-gcj-4.4 > > > > > > > lrwxrwxrwx 1 root root 18 Nov 14 2011 java-gcj-4.6 -> > > > > > java-1.5.0-gcj-4.6 > > > > > > > > > > > > > > and I'd like to be able to say something like > > > > > > > -D...=/usr/lib/jvm/java-7-openjdk-amd64 > > > > > > > so that maven will use the corresponding compiler and JVM. > > > > > > > > > > > > > > Does the default configuration already cares for this? If so, > which > > > > > are the > > > > > > > command-lins options? > > > > > > > > > > > > > > If not, I guess that this should be defined in a "profile" in > > > > > > > "settings.xml". If so, could someone post such a profile? > > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > Gilles > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > > > > > For additional commands, e-mail: dev-h...@commons.apache.org > > > > > > > > > > > > > > > > > > > > > > -- > > > > Xavier DETANT > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > > > For additional commands, e-mail: dev-h...@commons.apache.org > > > > > > > > > > > > -- > > Xavier DETANT > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > -- Xavier DETANT