Should renaming a project in Eclipse also rename project folder on file system?

31,980

Solution 1

It appears that renaming a project will only rename the underlying filesystem directory if the project was created with the "Use Default Location" checkbox selected (meaning the project is created in the workspace directory). If you create a project and specify a custom location outside the workspace, renaming that project in Eclipse does not rename the project's host directory. In that case, you'll probably want to:

  1. Rename the project in Eclipse (which will update any internal references and the .project file)
  2. Remove the project from your Eclipse Workbench view (making sure that the "Delete file contents" option is NOT selected in the delete confirmation dialog).
  3. Rename the project's directory in your filesystem.
  4. Import the project back into your Eclipse workspace.

I was surprised to learn this (I tested it with Eclipse 3.7), but it seems to be logical to me. The idea is that projects in the workspace folder are considered to be "under Eclipse control" as opposed to projects that are located in arbitrary places on your filesystem.

Solution 2

Use Refactor to rename the project name. It will rename the file/folder in filesystem as well.

Refactoring in Eclipse

Solution 3

Menu -> Refactor -> Move... (Shift + Alt + V).

In this window you can change name of the folder name and also change the path completely.

Solution 4

If the folder name is important, then change it manually. Keep in mind that you will have to re-open or re-import the the project into eclipse. After you rename the folder, Eclipse won't know where to find it.

Solution 5

In Eclipse Oxygen (4.7) the Move option is greyed and renaming the project does not rename the directory. However, if you switch to the Navigator view (may need to find it under Window > Show View > Navigator) the Move option will be available and it will rename the project's directory.

This is a lot faster than having to recreate the project or re-import it.

Share:
31,980
blue-sky
Author by

blue-sky

scala :: java

Updated on August 14, 2021

Comments

  • blue-sky
    blue-sky almost 3 years

    Should renaming a project in Eclipse also rename project folder on file system ?

    My project file system name remains the same even when I rename the file on Eclipse.

    Should I manually rename the project on the file system to same on Eclipse ?