> -----Original Message----- > From: Marc Farrow [mailto:[EMAIL PROTECTED] > Sent: Thursday, 31 August 2006 6:13 AM > To: ant-user > Subject: Jar Locking > > 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.
The jar file is locked because it is referenced in a classloader. The lock will be released once the classloader is garbage collected but that will not happen until all references to all classes defined by the jar are no longer referenced. If the jar file in question is referenced by Ant then chances are that your file will not be released until the Ant Project instance is no longer in use. The solution to the problem is to handle the creation and updating operations under two distinct projects. One project handles the creation of a new jar file, and the second project handles the replication of the jar (with the assumption that your second project does not include a classpath reference to the jar file). Cheers, Steve. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]