| Author |
Self Deleting an application
|
francy thattil
Greenhorn
Joined: Jan 28, 2004
Posts: 2
|
|
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.
|
 |
R Jelda
Greenhorn
Joined: May 13, 2002
Posts: 26
|
|
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
|
 |
Antoine Waugh
Ranch Hand
Joined: Jan 24, 2004
Posts: 66
|
|
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
|
B.C.S.T, SCJP, Hero
|
 |
Robert Paris
Ranch Hand
Joined: Jul 28, 2002
Posts: 585
|
|
|
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).
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
Can you launch the program from a bat or sh file?
|
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
|
 |
francy thattil
Greenhorn
Joined: Jan 28, 2004
Posts: 2
|
|
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.
|
 |
Ram Mohan
Ranch Hand
Joined: Jan 19, 2004
Posts: 44
|
|
Originally posted by Stan James: Can you launch the program from a bat or sh file?
actually i it is del MyProgram.class & del this.bat ---> this may work(not too sure)
|
If quitters never win, and winners never cheat, who's the idiot that said: Quit while you're ahead?
|
 |
himanshu patel
Ranch Hand
Joined: Feb 03, 2003
Posts: 205
|
|
Originally posted by Ram Mohan: <hr></blockquote> actually i it is del MyProgram.class & del this.bat ---> this may work(not too sure)[/QB]
erase and del both will work.
|
If you want to become a rich, do not work for others but make others to work for you.
|
 |
 |
|
|
subject: Self Deleting an application
|
|
|