Eclipse 工作区: 如何重命名工作区

文件菜单中没有重命名工作区的选项。是否建议关闭 eclipse、重命名文件夹并重新打开?我担心配置文件中一些潜在的悬空引用会破坏我的工作区/项目..。

谢谢!

76903 次浏览

Copying workspace to a new folder works. Any reference Eclipse itself needs is resolved using the relative workspace location. If you have added launchers, substitution variables, etc. that rely on the absolute workspace location, they will need to be reset.

Source : Renaming a workspace?

Yes, you can just rename the workspace directory and/or move it. However, you then have to tell Eclipse where the new workspace is. In 3.1, you can use 'switch workspace' to launch in a different location (under the File menu).

If you want to change it by hand, you can edit the appropriate entries in the files in the 'configuration' directory where Eclipse is stored.
You can change the org.eclipse.ui.ide.prefs file to set SHOW_WORKSPACE_SELECTION_DIALOG=true if you want to be asked each time Eclipse is run where the workspace is.

John, I think in the original workspace you imported projects and that the projects depend on links not on being physically in the same location of the worspace (even thay are there already but the dependency is on links). If so you have to remove the projects from the new (copied) worspace and then re-import them again.

I just did a:

File --> Import --> Maven --> Existing Maven Projects --> mention the new workspace location in "Root Directory" in the "Import Maven Projects" window

and it worked! All projects were imported properly.

BTW, I have Eclipse-Maven plugin "m2e" installed (http://wiki.eclipse.org/M2E_updatesite_and_gittags)

For simple renaming, it is not necessary to switch workspaces, unless the workspace you want to rename is not the one currently active.

Anyway, you can rename the current open workspace by choosing Eclipse->Preferences->General->Workspace and changing the option "Workspace name (shown in window title)" from the default's workspace folder name to whatever you want to call it. Then, restart Eclipse.

Suppose your workspace's folder is "/foo/bar/workspace" and you never changed its name before; its name was then the default "workspace". After you renamed it to, say, "my_workspace" and restarted Eclipse, the Eclipse's window title should show: "my_workspace - (some stuff that varies) - /foo/bar/workspace".

Note that this is NOT going to modify the workspace folder's name. You may have to create a new folder with the desired name, switch to that folder (whose workspace will have the same name, by default) and import existing projects into it, as some have suggested here.

Renaming Workspace folder worked for me. Close the eclipse, rename the workspace folder name, launch eclipse again. If you are using any project dependencies like user libraries,launchers etc, you have to relocate those to new location manually, from project build path.

2021 Update

In Eclipse 2020-12 (Windows 10), the "Workspace name (shown in window title)" preference mentioned in one answer is no longer there. Now, renaming a workspace (WS) requires a copy and delete operation.

Start by switch to another WS: File --> Switch Workspace --> select existing WS. Then rename the WS folder to desired new name. Switch to the new workspace folder and delete the old name:

  1. File --> Switch Workspace --> Other...
  2. Right-click old WS name --> Remove from launcher selection
  3. Click Browse --> select new workspace folder --> click Launch and Voila!

As mentioned in prior posts, depending on your setup some resource links may be broken. Delete the project without(!) removing it from disk, then import to new WS.