commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <gil...@harfang.homelinux.org>
Subject Re: [Math] How to select a specific JDK ?
Date Thu, 14 Jun 2012 21:24:07 GMT
On Thu, Jun 14, 2012 at 05:31:23PM +0100, sebb wrote:
> On 14 June 2012 02:15, Gilles Sadowski <gilles@harfang.homelinux.org> wrote:
> > Hello.
> >
> >> > [...]
> >
> > The following:
> >
> >> >> > 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
> >
> > is achieved by those respective commands:
> >
> >  $ JAVA_1_6_HOME=/usr/lib/jvm/java-6-sun mvn -X -Pjava-1.6 clean test
> >  $ JAVA_1_7_HOME=/usr/lib/jvm/java-7-openjdk-amd64 mvn -X -Pjava-1.7 clean test
> >
> > IIUC:
> >  JAVA_x_y_HOME is used to locate the "javac" executable
> 
> Sort of.
> 
> >  -Pjava-x.y selects the language level
> 
> -P selects the profile, which uses the relevant JAVA_1_n_HOME variable
> to locate the relevant Java installation.
> These variable were introduced specifically to support the java-x.y profiles.

The profile also sets "commons.compiler.compilerVersion", and I inferred
that this would define which version of the language is accepted by the
compiler. Is that correct?

> 
> >  JAVA_HOME has no effect
> >
> > This, however,
> >
> >> >> >  3. Compile with javac 1.6 and run with java 1.7
> >
> > is not so easy.  To run the tests with 1.7, one needs
> >
> >  $ JAVA_1_6_HOME=/usr/lib/jvm/java-6-sun mvn -Dcommons.surefire.java=/usr/lib/jvm/java-7-openjdk-amd64/bin/java
-X -Pjava-1.6 clean test
> 
> >> > [...]
> >
> > Much to my surprise, this
> >
> >  $ JAVA_1_7_HOME=/usr/lib/jvm/java-7-openjdk-amd64 mvn -Dcommons.surefire.java=/usr/lib/jvm/java-6-sun/bin/java
-X -Pjava-1.7 clean test
> >
> > (i.e. using java 1.6 to run classes compiled with javac 1.7) also works! Is
> > that expected? [I thought I'd get the "incompatible major.minor version"
> > exception.]
> 
> Unless you are using an updated version of the parent pom, the profile
> java-1.7 does not exist - this should report an error, but it might
> get lost in the -X output -  so the compilation will use your default
> java compiler.

Excerpt (with line numbers) of "commons-parent-24.pom":
---
    858     <profile>
    859       <id>java-1.7</id>
    860       <properties>
    861         <commons.compiler.fork>true</commons.compiler.fork>
    862           <commons.compiler.compilerVersion>1.7</commons.compiler.compilerVersion>
    863           <commons.compiler.javac>${JAVA_1_7_HOME}/bin/javac</commons.compiler.javac>
    864          <commons.surefire.java>${JAVA_1_7_HOME}/bin/java</commons.surefire.java>
    865       </properties>
    866     </profile>
---


Regards,
Gilles

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message