Re: [Math] How to select a specific JDK ?
Hello Gilles; Not sure this will fit your purpose but *toolchains* can be used to direct which JDK is used by Maven. You'd have to declare the various JDKs accessible in toolchains.xml (in $user.home/.m2) and configure the plugin in your pom.xml. By specifying the toolchains JDK vendor/version as properties in different profiles, it seems it should be possible to switch the JDK by running mvn with a -P flag. Cheers, Henrib -- View this message in context: http://apache-commons.680414.n4.nabble.com/Math-How-to-select-a-specific-JDK-tp4634995p4635099.html Sent from the Commons - Dev mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org
Re: [Math] How to select a specific JDK ?
On 15 June 2012 11:37, henrib hen...@apache.org wrote: Hello Gilles; Not sure this will fit your purpose but *toolchains* can be used to direct which JDK is used by Maven. You'd have to declare the various JDKs accessible in toolchains.xml (in $user.home/.m2) and configure the plugin in your pom.xml. By specifying the toolchains JDK vendor/version as properties in different profiles, it seems it should be possible to switch the JDK by running mvn with a -P flag. That sounds very similar to what we have set up currently, except that the user just needs to configure the JAVA_m_n_HOME properties, which can be done in settings.xml (also in $user.home/.m2). It's slightly simpler as there is no need currently to configure any plugins in any pom, as that has already been done in the parent pom. Looks like it is more effort to set up the toolchains.xml file initially - and AFAICT the setup cannot be bypassed by merely defining the JAVA_m_n_HOME property at run-time. However, it would be easier to configure for the case where one wants to use multiple vendors as well as multiple java versions. And having the Java definitions in a separate file would be a bit clearer. With the current arrangement, Commons components can be built with the default compiler without need to to do any additional setup; it's only necessary to define the JAVA_1_x_HOME property if they wish to use an alternate compiler via a -Pjava-1.x profile. We do have one minor issue we have with the current approach. The issue is that the manifest is generated by the java version used to run Maven, so may not be the same as the actual compiler version if the -Pjava-1.x profile is used. Can toolchains solve this? And if a developer only wants to build/test using their default compiler, would they still have to configure toolchains.xml? Cheers, Henrib -- View this message in context: http://apache-commons.680414.n4.nabble.com/Math-How-to-select-a-specific-JDK-tp4634995p4635099.html Sent from the Commons - Dev mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org
Re: [Math] How to select a specific JDK ?
On 14 June 2012 02:15, Gilles Sadowski gil...@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-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org
Re: [Math] How to select a specific JDK ?
On Thu, Jun 14, 2012 at 05:31:23PM +0100, sebb wrote: On 14 June 2012 02:15, Gilles Sadowski gil...@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 idjava-1.7/id 860 properties 861 commons.compiler.forktrue/commons.compiler.fork 862 commons.compiler.compilerVersion1.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-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org
Re: [Math] How to select a specific JDK ?
On 14 June 2012 22:24, Gilles Sadowski gil...@harfang.homelinux.org wrote: On Thu, Jun 14, 2012 at 05:31:23PM +0100, sebb wrote: On 14 June 2012 02:15, Gilles Sadowski gil...@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? It's used to set compilerVersion for the maven-compiler-plugin See: http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#compilerVersion Also: http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html The source and target properties are used to set the language version. 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 idjava-1.7/id 860 properties 861 commons.compiler.forktrue/commons.compiler.fork 862 commons.compiler.compilerVersion1.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 --- Oops, should have double-checked - I thought we had not yet added 1.7. Anyway my reasoning was wrong, sorry. Actually it's the java target version that matters here; the Java 1.7 compiler can generate code for Java 1.5 if the target is set to 1.5. However, the Java 1.7 compiler will reference the 1.7 runtime libraries, so if the 1.5 source code accidentally references something added since 1.5, it may still compile OK. And running against the 1.7 library will probably work too. That is why it's important to try and build and test the source code using the relevant compiler - it's actually the run-time libraries that matter, not generally the compiler version itself. For code that targets 1.5: - one should compile and test on 1.5, 1.6, 1.7. That ensures users with 1.5+ can run the code OK from source - also compile on 1.5 and test on 1.6 and 1.7. That ensures users with 1.6+ can run the 1.5 jar. Regards, Gilles - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org
Re: [Math] How to select a specific JDK ?
Yes, that switch is called PATH (environment variable). 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 -- In other words: what could be seen as a socially debilitating failure of character can certainly work to your advantage too. (Linus Torvalds, but the use in the signature tells something about me as well.) - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org
Re: [Math] How to select a specific JDK ?
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
Re: [Math] How to select a specific JDK ?
Hi, 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 groupIdorg.apache.maven.plugins/groupId artifactIdmaven-compiler-plugin/artifactId version2.4/version configuration encodingUTF-8/encoding source1.6/source target1.6/target compilerArguments Xlint:-unchecked / /compilerArguments /configuration /plugin See http://maven.apache.org/plugins/maven-compiler-plugin/ for more informations. 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
Re: [Math] How to select a specific JDK ?
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 groupIdorg.apache.maven.plugins/groupId artifactIdmaven-compiler-plugin/artifactId version2.4/version configuration encodingUTF-8/encoding source1.6/source target1.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
Re: [Math] How to select a specific JDK ?
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 groupIdorg.apache.maven.plugins/groupId artifactIdmaven-compiler-plugin/artifactId version2.4/version configuration encodingUTF-8/encoding source1.6/source target1.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
Re: [Math] How to select a specific JDK ?
You'd be better off using something like Jenkins for this. You could set up different jobs to run your builds under different conditions (windoze vs. linux, jdk7 vs. jdk6, etc.) On Wed, Jun 13, 2012 at 10:47 AM, Gilles Sadowski gil...@harfang.homelinux.org wrote: 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 groupIdorg.apache.maven.plugins/groupId artifactIdmaven-compiler-plugin/artifactId version2.4/version configuration encodingUTF-8/encoding source1.6/source target1.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
Re: [Math] How to select a specific JDK ?
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 : source1.6/source and target1.6/target in the maven's pom.xml. So if you use source1.7/source target1.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 groupIdorg.apache.maven.plugins/groupId artifactIdmaven-compiler-plugin/artifactId version2.4/version configuration encodingUTF-8/encoding source1.6/source target1.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
Re: [Math] How to select a specific JDK ?
I agree with James, Jenkins is a great choice for such tasks. That's what I do when I want to test a project with a different JVM, but have no time to set up Jenkins jobs. $ export JAVA_HOME=/opt/java/ibm... $ mvn clean test install Just my 0.02 cents :-) Cheers Bruno P. Kinoshita http://kinoshita.eti.br http://tupilabs.com - Original Message - From: James Carman ja...@carmanconsulting.com To: Commons Developers List dev@commons.apache.org Cc: Sent: Wednesday, 13 June 2012 11:53 AM Subject: Re: [Math] How to select a specific JDK ? You'd be better off using something like Jenkins for this. You could set up different jobs to run your builds under different conditions (windoze vs. linux, jdk7 vs. jdk6, etc.) On Wed, Jun 13, 2012 at 10:47 AM, Gilles Sadowski gil...@harfang.homelinux.org wrote: 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 groupIdorg.apache.maven.plugins/groupId artifactIdmaven-compiler-plugin/artifactId version2.4/version configuration encodingUTF-8/encoding source1.6/source target1.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
Re: [Math] How to select a specific JDK ?
On Wed, Jun 13, 2012 at 08:43:17AM -0700, Bruno P. Kinoshita wrote: I agree with James, Jenkins is a great choice for such tasks. That's what I do when I want to test a project with a different JVM, but have no time to set up Jenkins jobs. $ export JAVA_HOME=/opt/java/ibm... $ mvn clean test install OK. That's the answer to my question. The corollary is that I wasn't sure that the JAVA_HOME setting would take precedence over anything specified in the pom.xml and/or settings.xml. Do you confirm that if I set JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 maven will use all the executables that are locate under /usr/lib/jvm/java-7-openjdk-amd64/bin and nothing else? Thanks, Gilles Just my 0.02 cents :-) Cheers Bruno P. Kinoshita http://kinoshita.eti.br http://tupilabs.com - Original Message - From: James Carman ja...@carmanconsulting.com To: Commons Developers List dev@commons.apache.org Cc: Sent: Wednesday, 13 June 2012 11:53 AM Subject: Re: [Math] How to select a specific JDK ? You'd be better off using something like Jenkins for this. You could set up different jobs to run your builds under different conditions (windoze vs. linux, jdk7 vs. jdk6, etc.) On Wed, Jun 13, 2012 at 10:47 AM, Gilles Sadowski gil...@harfang.homelinux.org wrote: 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 groupIdorg.apache.maven.plugins/groupId artifactIdmaven-compiler-plugin/artifactId version2.4/version configuration encodingUTF-8/encoding source1.6/source target1.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
Re: [Math] How to select a specific JDK ?
On Wed, Jun 13, 2012 at 10:53:08AM -0400, James Carman wrote: You'd be better off using something like Jenkins for this. You could set up different jobs to run your builds under different conditions (windoze vs. linux, jdk7 vs. jdk6, etc.) I don't deny that such a tool is useful, but my purpose is not continuous integration; just, at some point in time, be able to compile and run the tests with different JDK versions/vendors (and expecting the same output). Best regards, Gilles On Wed, Jun 13, 2012 at 10:47 AM, Gilles Sadowski gil...@harfang.homelinux.org wrote: 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 groupIdorg.apache.maven.plugins/groupId artifactIdmaven-compiler-plugin/artifactId version2.4/version configuration encodingUTF-8/encoding source1.6/source target1.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
Re: [Math] How to select a specific JDK ?
On Wed, Jun 13, 2012 at 05:32:14PM +0200, Xavier Detant wrote: 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. Yes, but will they produce the same result? That's what I must investigate. I want to be able to select a given set of tools (javac, java, etc.), do the build, run the tests; then select another set of tools (different version, different vendor), do the build, run the tests, and compare the two outputs. Best, Gilles 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 : source1.6/source and target1.6/target in the maven's pom.xml. So if you use source1.7/source target1.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 groupIdorg.apache.maven.plugins/groupId artifactIdmaven-compiler-plugin/artifactId version2.4/version configuration encodingUTF-8/encoding source1.6/source target1.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
Re: [Math] How to select a specific JDK ?
Hi Gilles, I can't say for sure that this environment variable takes precedence over anything in the pom.xml, there may be some setting that override it or chooses a specific JVM :-) I'm compiling and testing commons-io using Sun JDK and IBM JDK setting the environment variable in a console. I know two ways to make sure that it is using the desired JVM: - in another console, while maven is running, I execute ps -ef | grep java to make sure that it is using the desired JVM. Sounds boring (and maybe it is :-) but I'm already used to this way. - instead of mvn clean test use mvn clean test -X. The -X flag turns Debug on. This way, in the beginning of the Maven output, you can see a lot of information about your environment (I use this flag in my Jenkins jobs too ;-). Below is an example excerpt using the IBM JVM. kinow@chuva:~/java/workspace/commons-io$ mvn clean test -e -X Apache Maven 3.0.4 (r1232337; 2012-01-17 06:44:56-0200) Maven home: /opt/java/apache-maven-3.0.4 Java version: 1.7.0, vendor: IBM Corporation Java home: /opt/java/ibm-java-x86_64-70/jre Default locale: en_US, platform encoding: UTF-8 OS name: linux, version: 3.2.0-2-amd64, arch: amd64, family: unix (...) Hope that helps Bruno P. Kinoshita http://kinoshita.eti.br http://tupilabs.com From: Gilles Sadowski gil...@harfang.homelinux.org To: dev@commons.apache.org Sent: Wednesday, 13 June 2012 1:00 PM Subject: Re: [Math] How to select a specific JDK ? On Wed, Jun 13, 2012 at 08:43:17AM -0700, Bruno P. Kinoshita wrote: I agree with James, Jenkins is a great choice for such tasks. That's what I do when I want to test a project with a different JVM, but have no time to set up Jenkins jobs. $ export JAVA_HOME=/opt/java/ibm... $ mvn clean test install OK. That's the answer to my question. The corollary is that I wasn't sure that the JAVA_HOME setting would take precedence over anything specified in the pom.xml and/or settings.xml. Do you confirm that if I set JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 maven will use all the executables that are locate under /usr/lib/jvm/java-7-openjdk-amd64/bin and nothing else? Thanks, Gilles Just my 0.02 cents :-) Cheers Bruno P. Kinoshita http://kinoshita.eti.br http://tupilabs.com - Original Message - From: James Carman ja...@carmanconsulting.com To: Commons Developers List dev@commons.apache.org Cc: Sent: Wednesday, 13 June 2012 11:53 AM Subject: Re: [Math] How to select a specific JDK ? You'd be better off using something like Jenkins for this. You could set up different jobs to run your builds under different conditions (windoze vs. linux, jdk7 vs. jdk6, etc.) On Wed, Jun 13, 2012 at 10:47 AM, Gilles Sadowski gil...@harfang.homelinux.org wrote: 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 groupIdorg.apache.maven.plugins/groupId artifactIdmaven-compiler-plugin/artifactId version2.4/version configuration encodingUTF-8/encoding source1.6/source target1.6/target compilerArguments
Re: [Math] How to select a specific JDK ?
Gilles Sadowski wrote: 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 Then you have setup your POM wrongly. Target should always be the lowest supported JDK. Nevertheless we have profiles in one of our parent POMs to select different JDK versions to compile and run the tests. My settings.xml contains: = % = profile idjava-1.3/id properties JAVA_1_3_HOME/opt/sun-jdk-1.3.1.21/JAVA_1_3_HOME /properties /profile profile idjava-1.4/id properties !--JAVA_1_4_HOME/opt/blackdown- jdk-1.4.2.03/JAVA_1_4_HOME-- JAVA_1_4_HOME/opt/ibm-jdk- bin-1.4.2.13_p9/JAVA_1_4_HOME /properties /profile profile idjava-1.5/id properties JAVA_1_5_HOME/opt/ibm-jdk- bin-1.5.0.12_p5/JAVA_1_5_HOME !--JAVA_1_5_HOME/opt/sun-jdk-1.5.0.22/JAVA_1_5_HOME-- /properties /profile profile idjava-1.6/id properties JAVA_1_6_HOME/opt/sun-jdk-1.6.0.24/JAVA_1_6_HOME /properties /profile = % = i.e. even if I run Maven with Java 7, I can use the profile to select something different. 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. You can use Java 7 to compile and use a different JDK to run the tests: $ java -version java version 1.7.0_04 Java(TM) SE Runtime Environment (build 1.7.0_04-b20) Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode) $ mvn clean package $ mvn -P java-1.5 test The animal sniffer plugin can ensure on top of it, that no Java 7 stuff is used, even if it is used to compile for Java 5. Cheers, Jörg - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org
Re: [Math] How to select a specific JDK ?
On Wed, Jun 13, 2012 at 06:59:05PM +0200, Jörg Schaible wrote: Gilles Sadowski wrote: 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 Then you have setup your POM wrongly. No, this output was obtained from running ant (not a commons project). It just shows that there is no forward compatibility. :-) Target should always be the lowest supported JDK. Nevertheless we have profiles in one of our parent POMs to select different JDK versions to compile and run the tests. My settings.xml contains: = % = profile idjava-1.3/id properties JAVA_1_3_HOME/opt/sun-jdk-1.3.1.21/JAVA_1_3_HOME /properties /profile profile idjava-1.4/id properties !--JAVA_1_4_HOME/opt/blackdown- jdk-1.4.2.03/JAVA_1_4_HOME-- JAVA_1_4_HOME/opt/ibm-jdk- bin-1.4.2.13_p9/JAVA_1_4_HOME /properties /profile profile idjava-1.5/id properties JAVA_1_5_HOME/opt/ibm-jdk- bin-1.5.0.12_p5/JAVA_1_5_HOME !--JAVA_1_5_HOME/opt/sun-jdk-1.5.0.22/JAVA_1_5_HOME-- /properties /profile profile idjava-1.6/id properties JAVA_1_6_HOME/opt/sun-jdk-1.6.0.24/JAVA_1_6_HOME /properties /profile = % = Yes, that was something like that which I had in mind. I posted here because I wanted to know whether this sort of customization can be done at a higher level. Like: Is it possible to import sections of the settings.xml file? E.g. someone could have set up a snippet in a file select_jdk.settings.xml with: profile idjava-1.6/id properties JAVA_1_6_HOME${JAVA_1_6_HOME}/JAVA_1_6_HOME /properties /profile which could be imported in our personal settings.xml; then, on the command-line: -DJAVA_1_6_HOME=/opt/sun-jdk-1.6.0.24 Thus what I mean: Is there a repository of snippets, or does everyone build up his own settings.xml by endless copy/paste? i.e. even if I run Maven with Java 7, I can use the profile to select something different. 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. You can use Java 7 to compile and use a different JDK to run the tests: $ java -version java version 1.7.0_04 Java(TM) SE Runtime Environment (build 1.7.0_04-b20) Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode) $ mvn clean package $ mvn -P java-1.5 test The animal sniffer plugin can ensure on top of it, that no Java 7 stuff is used, even if it is used to compile for Java 5. Thanks for the info, Gilles - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org
Re: [Math] How to select a specific JDK ?
On 13 June 2012 18:30, Gilles Sadowski gil...@harfang.homelinux.org wrote: On Wed, Jun 13, 2012 at 06:59:05PM +0200, Jörg Schaible wrote: Gilles Sadowski wrote: 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 Then you have setup your POM wrongly. No, this output was obtained from running ant (not a commons project). It just shows that there is no forward compatibility. :-) Target should always be the lowest supported JDK. Nevertheless we have profiles in one of our parent POMs to select different JDK versions to compile and run the tests. My settings.xml contains: = % = profile idjava-1.3/id properties JAVA_1_3_HOME/opt/sun-jdk-1.3.1.21/JAVA_1_3_HOME /properties /profile profile idjava-1.4/id properties !--JAVA_1_4_HOME/opt/blackdown- jdk-1.4.2.03/JAVA_1_4_HOME-- JAVA_1_4_HOME/opt/ibm-jdk- bin-1.4.2.13_p9/JAVA_1_4_HOME /properties /profile profile idjava-1.5/id properties JAVA_1_5_HOME/opt/ibm-jdk- bin-1.5.0.12_p5/JAVA_1_5_HOME !--JAVA_1_5_HOME/opt/sun-jdk-1.5.0.22/JAVA_1_5_HOME-- /properties /profile profile idjava-1.6/id properties JAVA_1_6_HOME/opt/sun-jdk-1.6.0.24/JAVA_1_6_HOME /properties /profile = % = Yes, that was something like that which I had in mind. I posted here because I wanted to know whether this sort of customization can be done at a higher level. Like: Is it possible to import sections of the settings.xml file? E.g. someone could have set up a snippet in a file select_jdk.settings.xml with: profile idjava-1.6/id properties JAVA_1_6_HOME${JAVA_1_6_HOME}/JAVA_1_6_HOME /properties /profile which could be imported in our personal settings.xml; then, on the command-line: -DJAVA_1_6_HOME=/opt/sun-jdk-1.6.0.24 Thus what I mean: Is there a repository of snippets, or does everyone build up his own settings.xml by endless copy/paste? http://commons.apache.org/commons-parent-pom.html#Testing_with_different_Java_versions i.e. even if I run Maven with Java 7, I can use the profile to select something different. 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. You can use Java 7 to compile and use a different JDK to run the tests: $ java -version java version 1.7.0_04 Java(TM) SE Runtime Environment (build 1.7.0_04-b20) Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode) $ mvn clean package $ mvn -P java-1.5 test The animal sniffer plugin can ensure on top of it, that no Java 7 stuff is used, even if it is used to compile for Java 5. Thanks for the info, Gilles - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org
Re: [Math] How to select a specific JDK ?
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 -Pjava-x.y selects the language level 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.] Best regards, Gilles - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org