ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Tuffs" <>
Subject Ant javac and jar update interaction.
Date Thu, 22 Mar 2001 23:57:30 GMT
Hello Ant Developers:

I just chased down a nasty problem in Ant 1.2 running under JDK 1.3, and didn't
see a report of this on the mailing lists.  I'm not subscribed to any-dev, but
feel free to mail me directly if you have any questions.

I had a build.xml file which first compiled some files and then did a jar-update
on jar-files which were also inputs to the compilation, something like this (see
below).  If the "javac" and the "jarupdate" targets were invoked in the same Ant
session, the jar-update would fail with an error on the jarfile:

Updating petstoreEjb.jar
  Myos = Windows 2000
  jar -uf ../../output/lib/petstoreEjb.jar . Error in writing existing jar file
  Result: 1

This problem may well be Windows specific, since it seems that the javac
"modern" compiler is locking the .jar file during use, and hence the "jar -uf"
is failing.  The simplest workaround is to specify <property
name="build.compiler" value="classic" /> to force the classic compiler to be
used, it seems not to have this problem.

  <target name="prepareEjb" depends="init">
    <javac srcdir="${enhydra.genic}" destdir="${}/${}">
        <pathelement location="${enhydra.liboutput}/build.jar" />
        <pathelement location="${enhydra.liboutput}/SharedApiService.jar" />
        <pathelement location="${enhydra.liboutput}/EjbService.jar" />
        <fileset dir="${example.output}/lib" >
          <include name="*.jar" />

  <target name="jarupdate">
    <property name="jar.dir" value="${}" />
    <echo>Updating ${}.${jar.type}</echo>
    <exec executable="jar" dir="${}/${jar.dir}">
      <arg line="-uf ../../output/lib/${}.${jar.type} ." />


Simon Tuffs.

Simon  Tuffs
Staff Engineer, Lutris Technologies Inc (831) 460-7482  ( (and musician

View raw message