Mariano Benitez wrote:
I am using antlibs, and I face the normal problem in windows of not being able of deleting the file while it is used.

I know this discussion must have probably taken place, I could not just find it :( Has there been any attempt to use File.deleteOnExit()
as an option for the task? or another task?

Note that using File.deleteOnExit from a task may cause it to not work as expected when Ant is being run in an embedded environment such as from an IDE, as F.dOE takes effect at VM exit time (not necessarily when Ant finishes the build).


Besides running Linux :-) I am not sure what to recommend... Jose points out that since Ant uses a custom class loader, that loader could release any JARs it has open when it is instructed to. That may work, but not always - if you once open a jar-protocol URLConnection from a JAR (which is common, if any code uses ThisClass.class.getResource("something") or similar idioms), the Sun JRE will open that JAR in a private cache somewhere and never close it while the JVM is running. On Windows, this means that JAR cannot be deleted or modified until the JVM is stopped.

The crudest but most effective workaround on Windows is simply to not read from the original JAR at all. Create a new File.createTempFile, set it to deleteOnExit, copy the original JAR to it, and open that instead. You pay a modest overhead in the time spent copying (might not be much compared to other costs), and some temporary disk usage in C:\TEMP.

-J.

--
Jesse Glick <mailto:[EMAIL PROTECTED]> x22801
NetBeans, Open APIs  <http://www.netbeans.org/>


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to