ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Prashant <>
Subject Re: Jar Locking
Date Thu, 31 Aug 2006 10:25:37 GMT
Take a look if this utility detailed in this blog can help you figure 
out which <java> process has the JAR locked.


Steve Loughran wrote:
> Marc Farrow wrote:
>> Everytime I run an ant task (either in NetBeans or from within Java 
>> Code),
>> the executing jar gets locked and I cannot delete the jar.  I am 
>> copying the
>> ant script and the dependent jar that it needs to run and then 
>> executing the
>> ant tasks.  Then I wish to delete the "new" copy I just created to 
>> run, but
>> a jar I am using is locked and will not allow me.  This in on a 
>> Windows 2000
>> machine.
>> Steps to recreate problem in NetBeans:
>> 1) Create a new Java Application that extends Ant and creates a Jar 
>> or even
>> uses an existing one such as ant-contrib.jar.
>> 2) Run an the new ant task from within the build script of another 
>> project
>> (via import command).
>> 3) Delete project created in step 1).
>> 4) Go to windows explorer and try to remove rest of sources, etc from 
>> the
>> folder that the project in step 1) was created in.
>> Steps to recreate similar problem using Ant Programmatically.
>>   (All actions happen within same instance of a java class).
>> 1)  Check out favorite project from your favorite source control
>> (programmatically).
>> 2)  Programmatically call the Ant script and build the project you just
>> checked out.
>> 3)  Once build has completed (and with no errors) try to delete the 
>> project
>> you just checked out.
>> Anyone have any suggestions to keep the "jars" from being locked after
>> execution of the Ant script?
> Ant does not lock jars after is runs, as JARs are only locked while 
> the java process is active
> If a JAR is locked, it means a running java program is using it. It 
> could be y our IDE, it could be something you exec with <java>.
> use the process explorer or JPS to find out what program you are 
> running with the JAR files. I think the windows server machines have 
> the ability to delete in-use files or find out who is using them; its 
> only windows workstation that is crippled.
> -steve
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message