?
Solved

delete program itself after execution

Posted on 2005-04-05
8
Medium Priority
?
1,290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

800 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