You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by William Settle <Wi...@alltel.com> on 2000/11/07 18:01:00 UTC

Cannot delete jar files

I hope someone can tell me what I'm doing wrong.

In my build file I jar two sets of packages and for discussion sake, I'll call
them a.jar and b.jar.  Both files are included in my classpath because classes
in b.jar import classes from a.jar and is required at compile time (I delete the
source files after successful jar creation).  After a successful build
everything's fine unless I re-run the build.  My "clean" target attempts to
delete existing jars but fails with a message that says:

BUILD FAILED
C:\autoBuild\build.xml:23: Unable to delete file D:\develop\jar\a.jar

I am running Windows 2000 and if I try to delete the jar files from the command
line, I get a message saying that it cannot be deleted because another process
is using it.  However, I can go to Explorer and delete it from there without
error.

The only process I know of that opened the jar file would have been Javac.

Do anyone have any ideas?

Thanks in advance,
Bill

Re: Cannot delete jar files

Posted by Peter Donald <do...@apache.org>.
At 08:51  8/11/00 +0100, you wrote:
>>>>>> "WS" == William Settle <Wi...@alltel.com> writes:
>
> WS> I jar two sets of packages and for discussion sake, I'll call
> WS> them a.jar and b.jar.  Both files are included in my classpath
>
>[...]
>
> WS> After a successful build everything's fine unless I re-run the
> WS> build.  My "clean" target attempts to delete existing jars but
> WS> fails with a message that says:
>
> WS> BUILD FAILED C:\autoBuild\build.xml:23: Unable to delete file
> WS> D:\develop\jar\a.jar
>
>I think you will never be able to delete a file that is in the JVM's
>CLASSPATH on Windows because the JVM locks it (and I vaguely remember
>it won't release that lock even if you don't need the file).

It will release it when all classes loaded from it are disposed of which
means shutting down the classloader. But not all JVMs actually do proper
garbage disposal ;(

Cheers,

Pete

*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power."          |
|       -Abraham Lincoln                               |
*------------------------------------------------------*

Re: Cannot delete jar files

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "WS" == William Settle <Wi...@alltel.com> writes:

 WS> I jar two sets of packages and for discussion sake, I'll call
 WS> them a.jar and b.jar.  Both files are included in my classpath

[...]

 WS> After a successful build everything's fine unless I re-run the
 WS> build.  My "clean" target attempts to delete existing jars but
 WS> fails with a message that says:

 WS> BUILD FAILED C:\autoBuild\build.xml:23: Unable to delete file
 WS> D:\develop\jar\a.jar

I think you will never be able to delete a file that is in the JVM's
CLASSPATH on Windows because the JVM locks it (and I vaguely remember
it won't release that lock even if you don't need the file).

Don't know of a workaround, sorry.

Stefan