?
Solved

delete program itself after execution

Posted on 2005-04-05
8
Medium Priority
?
1,299 Views
Last Modified: 2012-08-14
hi,
 how to write a program such that it will delete itself after execution?
 thanks..
0
Comment
Question by:luseng
6 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 13707151
Are you a graduated virus writer ;°)

You could try with File.deleteOnExit()
0
 
LVL 35

Accepted Solution

by:
TimYates earned 500 total points
ID: 13707237
We had this discussion recently:

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21356211.html

The answer is "you can't" as the classloader has cached the class, so it is in use, so it can't be deleted...

The long answer is you should be able to write a script to run your application, and have the script close the app once it is closed...

Tim
0
 
LVL 6

Expert Comment

by:CodingExperts
ID: 13707269
As TIM suggested. say you can write a Batch/shell script to first run the program and then delete the class file.

-CE
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:aozarov
ID: 13707375
And if you are afraid that a script will be too trivial then you can have a java prorgram that lunch the other program (using Runtime.getRuntim().exec(...) )
and then when the child Process is completed the java program that launched it will delete it.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13707461
But then of course, you get the problem of deleting the trivial java program itself ;-)
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13707575
Right, but my guess was that he doesn't care much about that "trivial java program" :)
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question