ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <>
Subject Re: remove old .class files
Date Wed, 29 Apr 2009 19:07:54 GMT
On Wed, Apr 29, 2009 at 2:03 PM, Mighty Tornado
<> wrote:
> Can I run the <javac> command in such a way that if I deleted java file
> which was previously compiled, it will remove its .class file from the
> classes directory when it builds again?

That's a limit on how Java works. The Java compiler compares the
timestamp on the resulting classfile with the source file. If the
timestamp on the source is older than the classfile, it doesn't do a

However, this is a one way check: Checking a *.java source against its
*.class object. The Java compiler doesn't go through all the
classfiles and see if there is a corresponding source file. In fact,
it may be almost impossible for this to happen since there isn't
necessarily always a one-to-one correspondence between a source file
and object file.

There is also a problem of knowing where the source is stored since it
is quite common to place the compiled classfiles into their own

That's why God  created the "ant clean" command. (You do have a
"clean" target in your build.xml file. Right?

David Weintraub

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message