ant: <java ...>-task with a different jvm version?

Discussion in 'Java' started by Andreas Leitgeb, Jul 2, 2008.

  1. For some project to build, some external tools are needed, which
    refuse to work with a java newer than 1.4.*. But for the rest of
    all tasks, we'd like to upgrade to use a newer java and/or javac.

    How can I tell ant to use a separate "java"-binary given with
    full path (using separate env-var) just for some task?

    I've already googled, but only found hints towards "-target"
    which is good for the compiler, but not for an external java-task,
    and questions on how to run "ant" (and everything else) with a
    different (than default) jvm. Also, I haven't found any options
    that would make java mimick/pretend an older version.

    PS: theoretically a newer jvm should always execute old class files
    correctly, unless the (closed-source) class files have an explicit
    check on the version and refuse to run with too new a version.

    PPS: the problematic task is sqlj.tools.Sqlj and it fails with:
    "Fehler: Für diese JDBC-Library ist JDK 1.4 erforderlich."
    (rough translation: "For this JDBC-lib, jdk 1.4 is necessary")
    when I run ant with a JAVA_HOME pointing to a newer java&javac.

    PPPS: I've written java in lowercase, because I refer to the
    such named program, or to a such-named ant-tag, not to the
    platform Java itself.
    Andreas Leitgeb, Jul 2, 2008
    #1
    1. Advertising

  2. On 2-7-2008 15:09, Andreas Leitgeb wrote:
    > For some project to build, some external tools are needed, which
    > refuse to work with a java newer than 1.4.*. But for the rest of
    > all tasks, we'd like to upgrade to use a newer java and/or javac.
    >
    > How can I tell ant to use a separate "java"-binary given with
    > full path (using separate env-var) just for some task?
    >


    You could use the jvm-attribute (for the java-task) or the
    executable-attribute (javac-task) in combination with the fork-attribute.

    See examples at the appropriate task description. Go to
    <http://ant.apache.org/manual/index.html>, then select "Ant Tasks" and
    "Core Tasks"
    --
    Regards,

    Roland
    Roland de Ruiter, Jul 2, 2008
    #2
    1. Advertising

  3. Roland de Ruiter <> wrote:
    > On 2-7-2008 15:09, Andreas Leitgeb wrote:
    >> For some project to build, some external tools are needed, which
    >> refuse to work with a java newer than 1.4.*. But for the rest of
    >> all tasks, we'd like to upgrade to use a newer java and/or javac.
    >> How can I tell ant to use a separate "java"-binary given with
    >> full path (using separate env-var) just for some task?


    > You could use the jvm-attribute (for the java-task) or the
    > executable-attribute (javac-task) in combination with the fork-attribute.


    Thanks a lot!

    > See examples at the appropriate task description. Go to
    ><http://ant.apache.org/manual/index.html>, then select "Ant Tasks" and
    > "Core Tasks"


    Bookmarked now. Obviously, googling doesn't always beat the product's
    own documentation :)
    Andreas Leitgeb, Jul 2, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lasse
    Replies:
    1
    Views:
    698
    Jon A. Cruz
    Jan 5, 2004
  2. Victor
    Replies:
    0
    Views:
    8,841
    Victor
    Sep 1, 2004
  3. krabhi
    Replies:
    1
    Views:
    9,300
    Marco Meschieri
    Aug 9, 2006
  4. teggy
    Replies:
    0
    Views:
    818
    teggy
    May 29, 2007
  5. Kit
    Replies:
    0
    Views:
    339
Loading...

Share This Page