Sign in to follow this  

Self-Deleting JAR

This topic is 3840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there any way to create a JAR file that deletes itself after it's run? Using something like: File file = new File("myjar.jar"); file.deleteOnExit(); Doesn't work and neither does using the del command on the command line because it doesn't actually delete the file it deletes what's inside of it, but I need the actual file to be deleted or the filename changed or something like that.

Share this post


Link to post
Share on other sites
As always I feel the need to ask why you are trying to do this

Share this post


Link to post
Share on other sites
Basically I have a program that stores a user selected file on my server. Then the program edits a file within another jar that tells that jar to download that particular file from my server. The user can then email that jar around so that when people open it it downloads the file from the server. Now in order for the jar to find out what file it's supposed to get from the server it has to open itself up as a jarfile and look through the jarentries within itself. In order to that it has to know its own filename which is a problem because if you have multiple copies of this jar in the same directory they will be renamed something like jarfile2.jar etc by windows so they wont be able to open themselves up. So I want it to delete itself after it finishes downloading the file from the server to save some hassle for the user.

If that didn't make sense there's a better explanation on my blog here.
If this is blogspam I don't mean it to be...it really does have an explanation on it.

[Edited by - PhlashStudios on July 14, 2007 10:20:29 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this