You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Siegmann Daniel, NY" <Da...@fja-us.com> on 2007/11/28 16:30:19 UTC

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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Compiling for older JVM with newer JDK

Posted by Wayne Fay <wa...@gmail.com>.
You should probably take a look at the retrotranslator plugin:
http://mojo.codehaus.org/retrotranslator-maven-plugin/

Wayne

On 11/28/07, Siegmann Daniel, NY <Da...@fja-us.com> wrote:
> 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: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

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


Re: Compiling for older JVM with newer JDK

Posted by nicolas de loof <ni...@gmail.com>.
Retrotranslator can backport most of java5 / java6 constructs to java 1.4

It can also verify there is no reference to unsuported methods based on a
verify classpaht. You then just have to provide the target JRE rt.jar as
verify (+ dependencies).

2007/11/28, Siegmann Daniel, NY <Da...@fja-us.com>:
>
> Thanks for the Retrotranslator suggestion. I wasn't aware of that
> option.
>
> How well would this work if I want to run Maven with JDK 1.6? I would
> still need to ensure the built artifact works with JDK 1.5, and the
> retrotranslator needs to be able to perform the translation (it mentions
> only JDK 1.5 support).
>
> Or should I just save myself a lot of trouble and be sure to only run
> Maven with JDK 1.5?
>
> --
> Daniel Siegmann
> FJA-US, Inc.
> 512 7th Ave. 15th Flr. New York, NY 10018
> (212) 840-2618 x139
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: Compiling for older JVM with newer JDK

Posted by "Siegmann Daniel, NY" <Da...@fja-us.com>.
Thanks for the Retrotranslator suggestion. I wasn't aware of that
option.

How well would this work if I want to run Maven with JDK 1.6? I would
still need to ensure the built artifact works with JDK 1.5, and the
retrotranslator needs to be able to perform the translation (it mentions
only JDK 1.5 support).

Or should I just save myself a lot of trouble and be sure to only run
Maven with JDK 1.5?

--
Daniel Siegmann
FJA-US, Inc.
512 7th Ave. 15th Flr. New York, NY 10018
(212) 840-2618 x139 

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


Re: Compiling for older JVM with newer JDK

Posted by nicolas de loof <ni...@gmail.com>.
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 <Da...@fja-us.com>:
>
> 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: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: Compiling for older JVM with newer JDK

Posted by "Siegmann Daniel, NY" <Da...@fja-us.com>.
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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


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