keepcalculator

06 Numbers and Powers

Recover Deleted Files from Eclipse: Full Guide

Card No. 06·27119 · Updated · Standard formula, shown below

Yes, you can recover deleted files from Eclipse using the built-in Local History feature, which automatically saves versions of your files as you edit them. This guide explains how to restore deleted or overwritten files, where Eclipse stores these backups, and what to do when Local History is unavailable.

How Eclipse Local History Works

Eclipse’s Local History is a versioning system that runs in the background. Every time you save a file, Eclipse stores a snapshot of its previous state in a hidden directory within your workspace. This is not the same as Git or SVN—Local History is per-file, automatic, and requires no setup. It keeps a limited number of versions (default is 50) and retains them for a configurable number of days (default is 7), after which older entries are purged.

The feature is especially useful when you accidentally delete a file or overwrite a method with bad code. Because Local History is stored locally, it works even if you never committed to a version control system.

Step-by-Step: Restore a Deleted File

If you deleted a file from your Eclipse project (either via the IDE or the file system), follow these steps:

  1. In the Project Explorer or Package Explorer, right-click on the folder or package where the file used to reside.
  2. Select Restore from Local History… from the context menu.
  3. In the dialog that opens, you’ll see a list of deleted files that were previously in that location. Select the file you want.
  4. On the right side, you’ll see a list of saved versions with timestamps. Choose the version you want to restore.
  5. Click Restore. The file is recreated in your project with the selected content.

If the file was in a package, make sure you right-click the correct package folder—Eclipse only shows deleted files that were directly under that location.

Recovering an Overwritten or Changed File

Local History also helps when you didn’t delete a file but made changes you regret. To revert to an earlier version:

  1. Right-click the file in the Project Explorer.
  2. Choose Compare With > Local History… to see differences, or Replace With > Local History… to directly pick an older version.
  3. Select a version from the list and click Replace.

This is handy when you accidentally deleted a large block of code and want to bring it back without undoing all your other changes.

Where Eclipse Stores Local History Files

Local History is saved in a folder named .metadata/.plugins/org.eclipse.core.resources/.history inside your workspace directory. Each saved version is stored as a file with a timestamp in its name (e.g., file_20240521143000.java). If you know the approximate time of the version you need, you can browse this folder manually using your operating system’s file explorer. However, the files are stored in a binary-ish format with a header, so opening them directly in a text editor may show extra characters at the beginning. For most users, using Eclipse’s restore dialog is safer and simpler.

Note that if you delete the entire workspace folder, Local History is gone too. It is not stored elsewhere.

When Local History Fails: Alternatives

Local History is not a complete safety net. It only tracks files that were saved in Eclipse, and it clears old versions after the retention period. If you need a file that was never saved, or if the workspace was cleaned, try these alternatives:

  • Version control systems (Git, SVN): If you committed your code regularly, you can restore the file from the repository with git checkout or the equivalent SVN command.
  • File recovery software: If you deleted the file from disk outside Eclipse, tools like Recuva or PhotoRec may recover it, but they are not guaranteed to work on SSDs due to TRIM.
  • Cloud sync: If your workspace is in a folder synced with Dropbox, OneDrive, or Google Drive, the file may be recoverable from the cloud service’s version history.
  • IDE backups: Some plugins (like Eclipse’s “Save Actions” or third-party backup tools) create additional backups. Check your plugin settings.

Preventing Future Data Loss

To avoid losing work again, consider these practices:

  • Increase Local History retention: Go to Window > Preferences > General > Workspace > Local History and set a higher number of days (e.g., 30) and more versions per file.
  • Use a version control system even for small projects. Initialize a Git repository and commit at least once a day.
  • Enable auto-save with a plugin like Save Actions or use Eclipse’s built-in auto-save (available in newer versions under File > Auto Save).
  • Regularly back up your workspace folder to an external drive or cloud storage.

Frequently Asked Questions

Can I recover a file that was deleted from the Recycle Bin?

If you deleted the file outside Eclipse (e.g., in Windows Explorer), Eclipse’s Local History may still have a copy if the file was previously saved in Eclipse. Right-click the parent folder in Eclipse and choose Restore from Local History. If that doesn’t work, check the Recycle Bin first, then try file recovery software.

How long does Eclipse keep Local History?

By default, Eclipse keeps up to 50 versions per file and retains them for 7 days. You can change these limits in Preferences > General > Workspace > Local History. After the retention period, old versions are permanently deleted.

Does Local History work for files created outside Eclipse?

No. Local History only tracks files that have been opened and saved within Eclipse. If you copy a file into the workspace without opening it in the IDE, it won’t have any history entries.

Can I recover a file after deleting the entire workspace?

If you delete the workspace folder, Local History is lost because it lives inside that folder. Your only hope is a file recovery tool or a backup from before the deletion. Always keep a copy of your workspace in version control.

Is Local History the same as Git?

No. Local History is a simple, automatic backup of individual files, stored locally. Git is a distributed version control system that tracks changes across a project, allows branching and merging, and stores history in a repository. Local History is not a substitute for Git, but it can be a quick safety net.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →