Sunspots

The Sun, eclipses, auroras and space weather explained

Eclipses

How to Recover a Deleted Project in Eclipse

· 6 min read · Eclipses

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

If you accidentally deleted a project in Eclipse, you can often get it back—provided the project files still exist on disk. Eclipse's delete action sometimes only removes the project from the workspace (without touching the files), and even when files are moved to the trash, you may restore them. This guide walks you through the recovery steps, from checking the workspace to using local history and file system backups.

What You'll Need

  • Access to your Eclipse workspace folder (usually under your user directory, e.g., C:\Users\YourName\eclipse-workspace or ~/eclipse-workspace).
  • If the project was under version control (Git, SVN), you'll need the repository URL or a local clone.
  • Basic file system navigation skills (using File Explorer or Finder).

Step-by-Step

  1. Check if the project files still exist on disk. Navigate to your workspace folder using your operating system's file manager. Look for a folder named after your project. If it's there, skip to Step 4. If not, proceed to Step 2.
  2. Look in the Recycle Bin (Windows) or Trash (macOS). If you deleted the project using the "Delete project contents on disk" option, Eclipse may have sent the files to the trash. Open the Recycle Bin/Trash, find the project folder, right-click it, and choose "Restore" (Windows) or "Put Back" (macOS).
  3. If not in the trash, check your file history or backups. On Windows, right-click the workspace folder in File Explorer, select "Properties," then the "Previous Versions" tab. On macOS, use Time Machine if you have it enabled. On Linux, check your backup system (e.g., Deja Dup, rsync snapshots). Restore the project folder to the workspace.
  4. Re-import the project into Eclipse. Open Eclipse. Go to File > Import. In the Import wizard, choose General > Existing Projects into Workspace. Click "Next."
  5. Select the project folder. In the "Select root directory" field, click "Browse..." and navigate to your workspace (or the location where you restored the project). Eclipse will list any projects it finds. Check the box next to your project. Ensure "Copy projects into workspace" is unchecked (unless you want a copy). Click "Finish."
  6. If the project was under version control, clone it again. If you cannot find any local copy, use your version control system. For Git: File > Import > Git > Projects from Git, then choose "Clone URI" and enter the repository URL. For SVN: File > Import > SVN > Projects from SVN. Follow the wizard to check out the project.
  7. Use Eclipse's Local History (if the project was recently open). Even if the files are gone, Eclipse may have local history for individual files. Create a new project with the same name (File > New > Project). Right-click the project, select "Restore from Local History..." and select the files you want to recover. This works best for files you edited recently.
  8. Check your workspace's .metadata folder. In the workspace folder, there is a hidden .metadata directory. It contains Eclipse's internal state, but not your source code. However, it may contain references to the project. If you re-import the project and it still doesn't appear, you may need to refresh the workspace (right-click in Project Explorer > Refresh).

Common Mistakes

  • Assuming "Delete" always removes files. In Eclipse, when you delete a project, a dialog asks if you want to "Delete project contents on disk." If you uncheck that, the files remain. Many users accidentally check it, thinking it's necessary.
  • Overwriting the workspace after deletion. If you create a new project with the same name before restoring the old one, Eclipse may overwrite or conflict. Always restore the original folder first.
  • Not checking the trash before using recovery tools. The trash is the simplest solution, yet often overlooked.
  • Importing the wrong folder. When importing, ensure you select the actual project folder (the one containing the .project file), not the parent workspace.

Tips

  • Always use version control. Commit your code regularly (at least daily) to Git or SVN. This is the most reliable safety net.
  • Keep a backup of your workspace. Use cloud storage (OneDrive, Google Drive) or an external drive. Schedule automatic backups.
  • Before deleting, double-check the dialog. Read the checkbox carefully. If you're unsure, keep the files (uncheck the box).
  • Use Eclipse's built-in local history. It saves versions of files as you edit, even without version control. You can restore older versions of files from the context menu.
  • If you use Maven or Gradle, you can regenerate most of the project structure. The pom.xml or build.gradle contains dependencies and build config; you can recreate the project and re-import dependencies.

Troubleshooting

Project appears in import but not in Project Explorer? After importing, if the project doesn't show, right-click in the Project Explorer and select "Refresh" (F5). Sometimes Eclipse needs to rescan the workspace.

Import wizard says "No projects are found to import"? This usually means the selected folder doesn't contain a valid .project file. Navigate to the exact project folder (the one with the .project file inside). If the file is missing, you may need to recreate it. You can create a new project with the same name and then copy your source files into it, then fix the build path.

Local History is empty? Local History only stores files that were opened/edited in Eclipse. If you never opened the project in Eclipse after creation, it may be empty. In that case, rely on file system backups or version control.

Restored files but project won't compile? After restoring, you may need to fix the build path. Right-click the project > Properties > Java Build Path. Ensure the source folder (e.g., src) is listed, and add any required libraries (like JRE System Library).

Deleted project was a Maven project? If you have the pom.xml, you can re-import it as a Maven project: File > Import > Maven > Existing Maven Projects, then select the folder containing the pom.xml.

Frequently Asked Questions

Does Eclipse permanently delete a project when I press Delete?

Not necessarily. Eclipse asks whether to delete the project contents from the disk. If you uncheck that option, the files remain. If you check it, the files are moved to the trash (unless you also empty the trash later).

Can I recover a project if I emptied the Recycle Bin?

Possibly, using third-party file recovery tools (like Recuva for Windows or PhotoRec for cross-platform). These tools scan the disk for remnants of deleted files. They work best if you act quickly and avoid writing new data to the same drive.

How do I prevent accidental deletion in the future?

Use version control (Git) and commit often. Also, consider setting up automatic backups of your workspace. In Eclipse, you can also right-click a project and select "Copy" to duplicate it as a safety net.

What is Eclipse Local History and how long does it keep files?

Local History stores copies of files when you save changes. By default, Eclipse keeps up to 7 days of history, but you can change this in Window > Preferences > General > Workspace > Local History. It's a per-file version history, not a project-level backup.

I deleted a project from the Project Explorer but the folder is still in the workspace. How do I get it back?

Simply re-import it using File > Import > General > Existing Projects into Workspace. Select the workspace folder and Eclipse will detect the project.

Can I recover a project if I don't have a backup and it's not in the trash?

Your best bet is a file recovery tool. If the project was under version control, clone it from the remote repository. If neither works, you may have to recreate the project structure and source files from memory or any other copies you might have (e.g., on a colleague's machine).