You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Bernshtam, Pavel" <Pa...@bmc.com> on 2007/02/27 10:32:43 UTC

Using alternative JDK

Hi!
How can I tell for one specific pom use a JDK different from my
JAVA_HOME for a compilation?

Thank you!


-------------------------------------------------------------------- 
Pavel Bernshtam				mobile:  +972-54-5583675
Senior Java Programmer		office:  +972-3-7675313
BMC Software Ltd. 			fax:     +972-3-6451100
email: pbernsht@bmc.com 	web:     http://www.bmc.com 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Using alternative JDK

Posted by Tomasz Pik <to...@gmail.com>.
On 2/27/07, Bernshtam, Pavel <Pa...@bmc.com> wrote:
> Hi!
> How can I tell for one specific pom use a JDK different from my
> JAVA_HOME for a compilation?

http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html
but - never tried myself...

HTH,
Tomek

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Using alternative JDK

Posted by Rémy Sanlaville <re...@gmail.com>.
Hi Niels,

Or, if you for some obscure reason need jdk 1.3:
>
>      <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-compiler-plugin</artifactId>
>        <configuration>
>          <fork>true</fork>
>          <executable><your-jdk1.3-javac.exe></executable>
>          <compilerVersion>1.3</compilerVersion>
>        </configuration>
>      </plugin>


Did you try this [1] ?

          <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-compiler-plugin</artifactId>
               <configuration>
                   <source>1.3</source>
                   <target>1.3</target>
                   <compilerArguments>

<bootclasspath>${settings.localRepository}/com/sun/rt/1.3.1_08/rt-1.3.1_08.jar</bootclasspath>
                   </compilerArguments>
               </configuration>
               <dependencies>
                   <dependency>
                       <groupId>com.sun</groupId>
                       <artifactId>rt</artifactId>
                       <version>1.3.1_08</version>
                   </dependency>
               </dependencies>
           </plugin>



[1]
http://docs.codehaus.org/display/MAVENUSER/Compile+and+Test+with+Different+JDK+Versions

Rémy

Re: Using alternative JDK

Posted by Niels Gylling <ng...@it-practice.dk>.
Or, if you for some obscure reason need jdk 1.3:

     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-compiler-plugin</artifactId>
       <configuration>
         <fork>true</fork>
         <executable><your-jdk1.3-javac.exe></executable>
         <compilerVersion>1.3</compilerVersion>
       </configuration>
     </plugin>


AND if for some other obscure reason use w2k OR have very many source 
files, the forked compiler command line will blow up and fail.

There you will need a compiler component that will provide the source 
file names as a @ argument to javac.

Who said m2 was easy?

/Niels

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Using java1.6 with java1.5 source

Posted by Erik Drolshammer <dr...@idi.ntnu.no>.
Thorsten Heit wrote:
>>> What error messages do you get? Have you tried "mvn -e -X ..."?
>> http://rafb.net/p/4Hfl1t68.html
>>
>> The NotImplementedException I can fix, but the error regarding 
>> org.apache.commons.validator remains a mystery to me.
> 
> It seems you're missing a dependency in your pom.xml....:
> 
> <dependencies>
>   ...
>   <dependency>
>     <groupId>commons-validator</groupId>
>     <artifactId>commons-validator</groupId>
>     <version>1.3.1</version> <!-- or whatever version you need -->
>   </dependency>
> </dependencies>

I have this in my pom. The problem went away though when I removed an 
exclusion (commons-validator) from another dependency. This dependency 
doesn't use it, so it seems strange to me.

But it works, so all is good. :)
Thanks!

-- 
Regards
Erik

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Using java1.6 with java1.5 source

Posted by Thorsten Heit <th...@gmx.de>.
> > What error messages do you get? Have you tried "mvn -e -X ..."?
> 
> http://rafb.net/p/4Hfl1t68.html
> 
> The NotImplementedException I can fix, but the error regarding 
> org.apache.commons.validator remains a mystery to me.

It seems you're missing a dependency in your pom.xml....:

<dependencies>
  ...
  <dependency>
    <groupId>commons-validator</groupId>
    <artifactId>commons-validator</groupId>
    <version>1.3.1</version> <!-- or whatever version you need -->
  </dependency>
</dependencies>


HTH

Thorsten

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Using java1.6 with java1.5 source

Posted by Erik Drolshammer <dr...@idi.ntnu.no>.
Thorsten Heit wrote:
>> My build fails if java1.6 is used instead of java1.5. (No java1.6 
>> specific functionality is employed.)

> What error messages do you get? Have you tried "mvn -e -X ..."?

http://rafb.net/p/4Hfl1t68.html

The NotImplementedException I can fix, but the error regarding 
org.apache.commons.validator remains a mystery to me.

-- 
Regards
Erik



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Using java1.6 with java1.5 source

Posted by Thorsten Heit <th...@gmx.de>.
Hi Erik,

> My build fails if java1.6 is used instead of java1.5. (No java1.6 
> specific functionality is employed.)
> 
> Shouldn't the following configuration fix this?
> 
> <plugin>
>    <artifactId>maven-compiler-plugin</artifactId>
>      <configuration>
>        <source>1.5</source>
>        <target>1.5</target>
>        <encoding>UTF-8</encoding>
>      </configuration>
> </plugin>

What error messages do you get? Have you tried "mvn -e -X ..."?


Cheers

Thorsten

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Using java1.6 with java1.5 source

Posted by Erik Drolshammer <dr...@idi.ntnu.no>.
Rémy Sanlaville wrote:
> Hi all,
> 
> Be aware of that configuration [1]
> 
>      <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-compiler-plugin</artifactId>
>        <configuration>
>          <source>1.4</source>
>          <target>1.4</target>
>        </configuration>
>      </plugin>


Hi!
My build fails if java1.6 is used instead of java1.5. (No java1.6 
specific functionality is employed.)

Shouldn't the following configuration fix this?

<plugin>
   <artifactId>maven-compiler-plugin</artifactId>
     <configuration>
       <source>1.5</source>
       <target>1.5</target>
       <encoding>UTF-8</encoding>
     </configuration>
</plugin>


If "yes", what else can be wrong?

-- 
Regards
Erik Drolshammer



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Using alternative JDK

Posted by Rémy Sanlaville <re...@gmail.com>.
Hi all,

Be aware of that configuration [1]

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.4</source>
          <target>1.4</target>
        </configuration>
      </plugin>

[1]
http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

means you want the compiled classes to be compatible with JVM 1.4 (-target
1.4) not that you compile with the JDK 1.4.
It's not the same. For example, if you use some specific Java5 API without
any specific Java5 token (enum, annotation...),  you can compile your
classes with a JDK 1.5 with a target 1.4 but not with the JDK 1.4.

If your really want to compile with an other JDK you need to specify the
rt.jar appropriate like this [2]

            <configuration>
              <source>1.4</source>
              <target>1.4</target>
              <compilerArguments>
                <verbose />
                <bootclasspath>${java14.home}/lib/rt.jar</bootclasspath>
              </compilerArguments>
            </configuration>

[2]
http://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html

Rémy

RE: Using alternative JDK

Posted by je...@accenture.com.
Hi pavel,

Check out the 2 following pages:

http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-u
sing-different-jdk.html
and
http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compi
ler-source-and-target.html

Cheers.

Jelle

-----Original Message-----
From: Bernshtam, Pavel [mailto:Pavel_Bernshtam@bmc.com] 
Sent: dinsdag 27 februari 2007 10:33
To: users@maven.apache.org
Subject: Using alternative JDK

Hi!
How can I tell for one specific pom use a JDK different from my
JAVA_HOME for a compilation?

Thank you!


-------------------------------------------------------------------- 
Pavel Bernshtam				mobile:  +972-54-5583675
Senior Java Programmer		office:  +972-3-7675313
BMC Software Ltd. 			fax:     +972-3-6451100
email: pbernsht@bmc.com 	web:     http://www.bmc.com 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org



This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org