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

  • Thread starter Andreas Leitgeb
  • Start date
A

Andreas Leitgeb

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.
 
R

Roland de Ruiter

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"
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top