How to recover a deleted file in Eclipse

Today I accidentally deleted a file in Eclipse. I didn't even know I did it until I ran my code. I am not even sure how I deleted it. My best guess is the current focus was on the project explorer and some strange key combo sent the file to the netherworld.

Eclipse, as you probably know, does not use the Windows 'recycling bin'. As luck would have it, the file was long, complex, just freshly debugged and not yet in version control.

I was able to recover the file by using the Restore from Local History option located in the context menu inside the project navigator.

"What?!?! I thought that only worked for files, not directories..." , you might say. I thought the same thing. Thankfully Eclipse is smart enough to know that when humans are behind the keyboard, expect the unexpected.

Try it and see for yourself.

Disclaimer: Not responsible for damage resulting from deleted files. Delete your files at your own risk.The posting and use of this information is governed by the laws of Uzbekistan. All legal proceedings must be filed in person on the third Tuesday of July at 1342 Uzbek Lane, Tashkent Uzbekistan. Accidentally deleting files can result in one or more of the following horrible incidents:

  • You could miss deadlines
  • Your boss could fire you
  • Your computer may stop functioning
  • Your computer might function incorrectly
  • Your computer could burst into flames
  • All the beer in your refrigerator could disappear
  • A puppy could die

There are no comments for this entry.

Add Comment Subscribe to Comments

1/18/08 9:02 AM # Posted By Stephen Moretti

Subversion, Subversive/Subclipse and the Team menu are also pretty useful for making sure you don't lose files or changes. ;)

1/18/08 10:00 AM # Posted By david buhler

I have always wondered if there was a way to do this.

1/18/08 3:21 PM # Posted By Dan Wilson


Yeah, I am a large fan of subversion. I use it on all my personal projects and recommend it to all my clients. What I meant in the post above by "just freshly debugged and not yet in version control." was that while the file was looking really good, I had not committed the file as it was just yet. I do not line checking in versions that do not run.

I am, however, open to ideas. At what stage of developing a component do you commit?


1/21/08 4:33 AM # Posted By jax

Restore from Local History works like a charm. Except when you accidentally delete an entire project and also check 'also delete contents'.
I did this the other week, and there's no coming back from it.. :-(

1/21/08 5:18 AM # Posted By Stephen Moretti

> At what stage of developing a component do you commit?

If I'm working in a branch I tend to hold on to changes until they are working. This is because most times branch changes are pretty small bug fixes and minor functional additions, so it doesn't actually take that long to make those changes anyway.

If I'm working in the trunk, I try to remember to submit in every couple of hours. Usually when I've added some discrete bit of functionality (whether it works or not). I've had issues in the past where I've wanted to go back to a revision in the local history only to discover that its outside of the local history range. I tend to work on the premise that trunk, while it should work, is mostly likely going to be broken.

2/28/08 6:10 AM # Posted By Roland

Thanks man! You saved my life!

5/16/08 3:07 AM # Posted By Ajay Kumar

Thats really made for me most useful, unfortunately number of files get deleted I was really totally sad, whether is it any way to get back my very suspecious files but after googling ur response given me a very very useful way to recovered it very easily. After all just I wanted to say Eclipse is really a powerful tool.

Very very thanks to you for your such valuable posted response....

5/20/08 1:27 AM # Posted By Eswar.Annapureddy

Really greatly helpful. I saved around 48 hrs work with this feature.

6/27/08 11:17 AM # Posted By Markus

Thank you so much, I only knew the context menu for an existing file. You saved me about 18 hours of work!!!

7/8/08 3:27 PM # Posted By Greg

Thank god for this feature :D I'm new to svn and I didn't realize that revert deletes any packages that aren't in version control yet. So when I clicked revert to fix some minor issue, I lost a package with about 50 hours of work invested in it. It took me 30 minutes to find this solution and now I'm saved from the wrath of my superiors :] :]

8/29/08 5:00 PM # Posted By im a huge fan

Hell yeah, your tip saved the day, thanks!

9/11/08 6:20 PM # Posted By JB

Thank you soooo much. I was looking everywhere for how to get my file back. You are the MAN!

10/31/08 9:41 AM # Posted By Joe Zack

I had the same problem and solution as well. I !swear! eclipse ate 3 of my files, I just wish I knew how to not repeat it.

Just had to empathize w/ you!

12/16/08 10:28 AM # Posted By Sriram N

You made my day ! Thanks

3/4/09 8:16 PM # Posted By natalie

man I love you! (and eclipse off course :)

3/29/09 12:17 AM # Posted By Carlton Dickson

Mate, I love you as well! I know exactly how I did it...I was pressing ctrl + z (undo) thinking I was undoing changes in my source code but in fact my focus was on the project view (my files) and it was undoing the ones that I created...Eclipse should sort this issue out as I'm sure many have made this mistake and haven't been lucky enough to find this solution!

4/29/09 3:30 AM # Posted By Dan Parker

OH are a lifesaver!!!! I just checked my work into Dev and it said a file was missing...evidently I deleted it accidentally...first time for that one...THANKS for posting this!!!!!

11/9/09 9:40 AM # Posted By Raghu

Thanks for the post, it was very useful.

11/10/09 2:41 PM # Posted By Cristi

Yes, Carl is right! I second him on the CTRL + Z issue if pressed in the Navigator pane, and it's a "pane" in the arse cause it really does undo changes made at the file structure level (creation / renaming), which are very common tasks accomplished by a developer. However it does not undo the deletion of files, just as well as it does not magically redo the deleted files (by accidentally pressing ctrl + z) if you think of trying ctrl + y to restore.

In my opinion this is pretty critical (deleting files) and it should be simply fixed by showing a dialog box, similar to the one shown when you're trying to delete a file by pressing the "delete" key.

11/27/09 8:10 AM # Posted By christian

you're a lifesafer, THANKS!

12/17/09 10:22 AM # Posted By Anton

Thank you man! You've just saved 5 days of my life!

3/7/10 4:32 PM # Posted By Some GUy


3/29/10 8:02 AM # Posted By Stephen Steven

Thanks !

4/30/10 3:45 AM # Posted By Pavan

Thanks a lot. Once again a life-saver.

5/3/10 3:25 PM # Posted By DimOn

Hey man! You probably saved me couple days!! I'm sending you some virtual packs of beer!!!! :)

5/9/10 8:09 AM # Posted By Schmuli

Thanks, with such a clear explanation, it's no wonder you're the first google result for "eclipse undo delete".

5/16/10 3:22 AM # Posted By Sulagna Majumder

THANKS A LOT...............

5/17/10 1:04 AM # Posted By sf

Aww, this was a really quality post. In theory I’d like to write like this too – taking time and real effort to make a good article… but what can I say… I procrastinate alot and never seem to get something done.

5/18/10 9:47 AM # Posted By Moi Aussi

Thank you. I agree there should be a redo of your undo though...

5/23/10 1:02 AM # Posted By Carlos

You are a genius! I had just accidentaly -and idiotically- lost 25-30 hours of work. You saved my day. Thanks a million.

I'm more and more in love with eclipse every day.

7/9/10 10:19 AM # Posted By Chilloutman

You are my HERO!! I love you man! You saved me about 3 days of work!

7/16/10 3:47 PM # Posted By K

Found this page after rewrote the class I accidentally deleted but this will be helpful in the future in case of a mishap.


7/28/10 11:01 AM # Posted By Jared

there is a bug in subversive where if you're checking in a file for the first time with some revisions it sometimes will delete the new file. This happened to me about 15 minutes ago with a file I put a good amount of work in to... and you saved my day. Thank you!

8/1/10 10:40 PM # Posted By muosa

Thanks Man

8/10/10 2:21 PM # Posted By Laurie

I almost slit my wrists while trying to figure out how to recover files I didn't even delete.

Thank you for this page!

8/14/10 1:26 AM # Posted By digitalpbk

Phewww... thanks a loot for this ... I was blank for a minute when I accidently deleted the file I was working for 2 days ... !!!

10/3/10 3:02 AM # Posted By moncler

Site information useful, I believe you must spend a lot of time in it, thanks so much. Looking forward to receiving new changes next time.

10/7/10 10:46 AM # Posted By Alireza Pazirandeh

hey! thanks alot! saved me a whole day of programming :D

10/11/10 10:12 AM # Posted By Lucie

Thanks a lot

11/21/10 4:08 AM # Posted By M P

Thanks man, saved several hours of work.

1/17/11 11:26 AM # Posted By Shane

Echoing what everyone else said. Thank you! You saved me many days of work (and my sanity)!

1/20/11 10:23 PM # Posted By Nash

Thanks you saved me hours worth of work

1/21/11 5:13 AM # Posted By murugan

Thanks, This is blog was really helped me a lot.

2/10/11 6:53 AM # Posted By Kiran

Thanks, saved my day. I literally crossed my fingers while restoring a deleted file.

2/24/11 3:40 AM # Posted By izi

Big Thanks for that tip!!!

2/25/11 12:55 AM # Posted By Sam

Saved my day!

(even after 3 years of OP date!)

3/3/11 12:50 PM # Posted By Tez

saved my life... tnx

3/17/11 6:47 AM # Posted By Anjali

Thats really Best!!! It Saved a big loss

4/8/11 8:19 AM # Posted By Ashwin

Saved my butt!!! thanks a lot..

4/8/11 8:22 AM # Posted By Ashwin

Saved my life man!!!!! I had lost my 3 days of work... Thanks a lot... :)

4/28/11 10:22 AM # Posted By Josh

Saved my life, thanks!

5/25/11 8:56 AM # Posted By thaw

Hi, if i deleted the whole project, how can i recover it.
please help me

6/17/11 3:54 AM # Posted By Aj


6/30/11 6:29 PM # Posted By Pat

Wow! Three and a half years later, and your post is still saving people! Thanks! (Only about four hours of work for me, but man, that's enough!)

7/1/11 6:10 PM # Posted By Brant

Indeed, thank you sir. Saved me two days of work. :)

7/9/11 8:26 AM # Posted By pegas

Excelent !!!
You saved me 2 hours of work !

Thank you

8/10/11 2:12 PM # Posted By Cathy

You saved me. Thank you so very much!!

8/19/11 1:58 AM # Posted By luffysan

Many many thank you. You save my work

8/19/11 9:50 AM # Posted By Flo

It's friday evening 5pm and you just f***ing rule 'cause my week end was about to be a bad one!

8/22/11 1:28 PM # Posted By L

THANK YOU DAN !! really appreciate the folks who post solutions :)

8/30/11 1:10 AM # Posted By John

Lucky you and me :)

8/30/11 5:24 AM # Posted By Swapnil V

Thank u very much for your valuable support.
I was about to suicide that i have accidentally deleted my algorithm.

1/3/12 3:08 AM # Posted By Mok

Thank you very much!

You just saved my Day!

1/4/12 12:31 AM # Posted By sm

Thanks. Saved my late night journey. Thanks a lot.

1/16/12 5:11 AM # Posted By uicsog

Thanks! I was already opening the window ready to jump :P

1/21/12 8:10 AM # Posted By Giz

I was committing to SVN (Right Click) and hit the delete instead of add!! I was nearly sick as it was over 1200 lines of a major module!! You saved my life.. Did not know that Eclipse did this as I rely on SVN so much.

1/24/12 4:06 AM # Posted By novice

Thanks you saved me!

1/30/12 12:26 AM # Posted By Vinod Patil

Thank You Very Much....Thank's a lot...!You Save me...again Thank You...!

2/2/12 6:32 AM # Posted By Arend

Saved at the eleventh hour!

2/22/12 6:27 AM # Posted By Stefan

you saved hours of work to me

3/19/12 3:55 PM # Posted By Chris Burnham

Another helped person!

3/22/12 2:47 PM # Posted By anonymous

Great Tip!! Saved my day :-)

Thank you!!

4/12/12 1:35 PM # Posted By Madhu

Thanks a lot!!!!! You saved my life!!!!

5/7/12 2:16 PM # Posted By Aluisio Vanzolin

Damn .. u save my day!

5/7/12 9:12 PM # Posted By Milko

God bless you!

5/15/12 10:48 AM # Posted By Beat

Lifesaver post! THANKS!

5/15/12 5:21 PM # Posted By Varun

Thanks a lot!!!

6/16/12 4:40 AM # Posted By Rami

You saved me hours of working, Thanks !!

6/19/12 4:37 AM # Posted By Ted

Awesome man, thank you very much.

7/10/12 4:59 PM # Posted By vin

wow.. you saved me man..Thanks a lot!

7/16/12 4:26 AM # Posted By Martin

Godsent post!

8/6/12 11:47 AM # Posted By Oscar

massive thanks, you just saved me a huge amount of time. much appreciated!!

8/11/12 8:52 AM # Posted By Monero Jeanniton

you save my health because without this post I will have a big headache because I just delete my java code which contains hundreds of lines wuch took me a lot of much time to write and debug

8/16/12 12:31 PM # Posted By dat

thanks buddy

8/17/12 7:53 AM # Posted By Brian Stapleton

Thanks this really saved me a ton of time!

10/3/12 9:21 PM # Posted By Dro

This saved my butt! 6 hours of work, I was freaking out. Looks like I should commit to SVN more often.

10/26/12 7:20 AM # Posted By divya

Thanks a lot..:-):-).. I'm happy i got my files back.. Thanks again..:-):-)..

12/3/12 4:34 AM # Posted By murali


12/14/12 3:28 PM # Posted By gotSaved

was about to wrap up my work and before checkin i realized i did delete a file accidentally... my heart dropped...but here I am Smiling.. Thanks bunch

1/2/13 12:36 AM # Posted By Sandeep

Thank a lot!! this saved my entire week's work.

1/31/13 4:22 AM # Posted By CP

Thank You for posting this, today i recoverd code thanks to this article.Saved lot of time :)

1/31/13 8:56 PM # Posted By Hardy

1000 Thanks !!!!

2/5/13 6:29 PM # Posted By Life saver

Thanks dude. This thing is still useful now in 2013

2/20/13 8:38 PM # Posted By chris

You are a life saver!!!! I was being lazy and not committing a new mvn project. You saved me a week worth of work. I won't be so careless again.

2/22/13 3:19 AM # Posted By Rat

Awesome blog! thanks for ur useful blog...

2/22/13 3:22 AM # Posted By Rat

U r Awesome...Tanks a lot!

2/22/13 3:25 AM # Posted By Rat

No Words!

2/23/13 9:41 PM # Posted By patricia

you just save my life!!!!

2/27/13 2:04 AM # Posted By Roger the Coder

Whew! Thanks! Saved me!

3/14/13 1:59 AM # Posted By Tomas

Thank you very much!!!

4/16/13 11:33 AM # Posted By Ni

A pint of beer from Lviv. Thank you MAN!!!

9/20/13 11:33 AM # Posted By Paul Carrick

Thanks so much. A life saver!

10/2/13 2:43 AM # Posted By Greg

Exactly what I needed after issuing 'svn --force remove ..' Thanks!

10/19/13 4:01 AM # Posted By Hussain Badusha

Thanks very much
It works greatly..........

12/26/13 11:35 AM # Posted By Himanshu Gahlaut

Thanks a lot! This saved my day

1/28/14 10:48 PM # Posted By Vijayan

It works.. Thanks Dude.. You saved my day...

2/10/14 7:52 AM # Posted By Guillaume

Thanks! Saved my ass :)

2/13/14 12:14 PM # Posted By SUMANTH P

Thank you very much.., saved me

3/4/14 9:40 PM # Posted By Sabahath

Hi,Thank u thank u very much...i deleted one file when my project is about to release.because of that release got delayed for 2 days.i was using project explorer now in navogator i got that very thank full to u...thanks alot again..


3/29/14 4:03 AM # Posted By Uriel

Thank a lot

4/22/14 9:31 PM # Posted By Manju

Thank you so much. you've saved 3 days of my work. Once again thanks a lot

4/24/14 8:46 AM # Posted By almost out of luck

Bless you Dan Wilson, whoever you are! I love you!

9/19/14 4:01 AM # Posted By Pramod

Thanks you so much dude

9/30/14 4:23 AM # Posted By sruthi

thanks a lot.... it helped me to recover data deleted from my java file which is very important part of my current project

10/7/14 3:10 PM # Posted By r

Thank you so much! I didn't think that it is possible to recover a deleted file within Eclipse but I gave it a try and finally it saved a lot of work for me :)
Thanks again!

10/10/14 11:47 PM # Posted By varun

Thanks A lot

10/25/14 7:21 AM # Posted By Cindy

Thanks for saving me too! I usually don't commit until a small feature is complete, and I deleted a new file by accident.

1/5/15 7:20 AM # Posted By Rob

Thanks! This saved me BIG TIME!

2/2/15 12:17 AM # Posted By Mon

Awesome help! Just saved my days of work. :)

2/22/15 9:39 PM # Posted By sirishma

thanks a lot

3/23/15 6:41 AM # Posted By Asaf

You just saved me hours of work, thank you very very much :-)

6/8/15 12:46 PM # Posted By Samual

You save me. My hero of the day!

6/16/15 2:17 PM # Posted By Paul

Thank you, this saved my project with 2 weeks of work.

7/10/15 5:08 AM # Posted By Mirko

Thank you so much! I used this feature to recover some configuration files of a deleted Server... Awesome!!!!

Add Comment Subscribe to Comments