Plz. can anyone help me in deleting the application file after it has been closed. I know I can use deleteOnExit() of java.io.File, but it doesn't seem to work in Windows.
Hi, why don't you delete the file in finalize() method of the Application class. Regards, Jelda
"If you have an apple and I have an apple and we exchange apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas." -George Bernard Shaw
heyas, please note: the finalize method is not necessarily going to be executed. it can/will be run by the JVM just before garbage collection, but unless you remove all ties to the object's reference, and manually call System.gc() then there is no garentee that this approach will work. -twans
You can't do that. Anything that is being run cannot be deleted as it is a process in use. What you could do (and this is dirty, bad architecture) is use Runtime.exec() to (on windows) use the "AT" command to schedule a delete command on your java code files. Again, this is not the best idea and it's platform dependant (so you'd have to have a way to do this on linux too - cron would do it).
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Since I wanted an Application, I had created a .jar file with all .class files bundled in it. And i tried assigning a reference to this .jar file and use deleteOnExit() i.e. import java.io.*; public class DeleteMe { public static void main(String[] args) throws Throwable { File f = new File("DeleteMe.jar"); f.deleteOnExit(); } } But, still it does not budge(gets deleted) and remains still on the file system.