commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: [Math] How to select a specific JDK ?
Date Thu, 14 Jun 2012 16:31:23 GMT
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.

>  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.

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

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


Mime
View raw message