I can suggest two options :

1. You want to ensure the compiled code will not make reference to methods
introduces by java 5+ and available at compile time, but not on the target
runtime

You can simply use the bootclasspath option of the compiler. I'm doing the
same to target java 1.3 :

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


2. You want your code to run on java 1.4, without having to check anything
from your developer environement

Use retortranslator, that can
- transform your classes after compilation to use alternative classes to
Java5
- check your classes to NOT use java 5 methods, based on a verifiy classpath


Nico.


2007/11/28, Siegmann Daniel, NY <[EMAIL PROTECTED]>:
>
> Sorry, I left out part of what I intended to ask...
>
> I am aware of the possibility of forking off with a different javac [1].
> I am actually wondering if this is the best way to handle this
> situation, or if there is a way to use the same JDK that Maven is
> running with but still be certain the artifact will run with an older
> JVM.
>
> [1]
> http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-u
> sing-different-jdk.html
>
> ~Daniel
>
> -----Original Message-----
> From: Siegmann Daniel, NY
> Sent: Wednesday, November 28, 2007 10:30 AM
> To: Maven Users List
> Subject: Compiling for older JVM with newer JDK
>
> I have a project where the code is Java 1.4 (source and target).
> However, I want to be able to run Maven with a newer JDK and still be
> certain the produced artifact (jar) will run on a 1.4 JVM.
>
> I am under the impression that configuring maven-compiler-plugin with
> source and target 1.4 is not sufficient because the code could still be
> using stuff from the Java libraries which is only available in a later
> version of Java.
>
> What is the best way to accomplish this in Maven? I'm looking for a
> solution that will be completely portable, so the actual JDK being used
> to run Maven will be irrelevant.
>
> --
> Daniel Siegmann
> FJA-US, Inc.
> 512 7th Ave. 15th Flr. New York, NY 10018
> (212) 840-2618 x139
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to