eclipse workspace: how to rename workspace - eclipse

There is no option in the file menu to rename a workspace. Is the recommended practice to close eclipse, rename the folder, and re-open? I worry about some potential dangling references in configuration files corrupting my workspace/projects...
Thanks!

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.

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.

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.

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)

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:
File --> Switch Workspace --> Other...
Right-click old WS name --> Remove from launcher selection
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.

Related

What is difference between Project Path and Workspace in spring Tool suite?

There's an option to start a project in Spring Tool Suite we can select our Project path and Workspace. Where I need to choose if I need to save project files?
I need to save files on D:\3rd year\SQA location. Where I need to put this, in Project path or Workspace?
Updated
In this window when I click "Add a local project" link in below the above window appear.
The workspace is a concept of Eclipse and contains the metadata for settings and which projects belong to the workspace. You can put your projects into your workspace folder, but you don't have to. You can put your projects anywhere you like. And you can import projects from anywhere into your workspace.
When creating new projects in Eclipse/STS, the wizard usually asks you where to store the project itself. The default is often set to the workspace location, but you can change that and put the project anywhere.
Therefore, in your example, the project path is probably the path where your project itself is stored (or will be stored), whereas the workspace location is the location where your workspace metadata information will be stored.
Hope this helps!

Eclipse is creating an old folder instead of using the new one

I used to have Eclipse in a folder but then I decided to move the folder for Eclipse into a different folder. I deleted the old folder because I no longer needed it. Now Eclipse creates the old folder it used to be located in every time I start Eclipse.
Just to be clear: Eclipse is in folder "eclipse stuff" which got moved from folder A to folder B (both are on the Desktop) and folder A got deleted and now when Eclipse is opened it creates "Desktop\A\eclipse stuff\" with a sequence of folders within it.
My best guess is it is storing default settings in there (based on the names of the things in the folders) and that the directory it stores these "default settings" in is somewhere in Eclipse's settings. I don't know what settings it would be in. How can I change this setting?
You need to switch the workspace. File -> Switch Workspace -> other and choose the new folder. Restarting should preserve the new default workspace. If not, you can also delete old workspace locations in Eclipse setting: Window -> Preferences => General -> Startup and Shutdown -> Workspaces contains a list of all known workspaces. You can delete it there.

What is the runtime-EclipseApplication folder for, and can I delete it safely?

I'm trying to organise the directory structure of my projects' source code and the eclipse workspace etc.
I found a folder called runtime-EclipseApplication in a high level folder outside the directories where I keep my workspace and projects.
What is this folder, when/why is it created and is it safe to delete?
This is the default for the workspace name when you use Run As > Eclipse Application.
You can look in the Eclipse Applications section of the Run > Run Configurations dialog to see what (if anything) is using this workspace. The workspace name is shown in the Location field of the Main tab.

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

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 ?
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:
Rename the project in Eclipse (which will update any internal references and the .project file)
Remove the project from your Eclipse Workbench view (making sure that the "Delete file contents" option is NOT selected in the delete confirmation dialog).
Rename the project's directory in your filesystem.
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.
Use Refactor to rename the project name. It will rename the file/folder in filesystem as well.
Menu -> Refactor -> Move... (Shift + Alt + V).
In this window you can change name of the folder name and also change the path completely.
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.
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.
If your project is a Maven project to rename, do steps as followed:
Open Context Menu on your project > Refactor > Rename Maven Artifact.
Change Group or ID.
Check "Rename Eclipse project in Workspace".
press OK button.
Update maven project by Context Menu > Maven > Update Project.
Using eclipse Neon 4.6.3, renaming does not work. You will have to do what E-Ritz said in his answer.
It is also worth mentioning that if you are importing a project as a Maven project (via Import... -> Existing Maven Projects), the project name will be taken from the pom.xml rather than the folder. So you should also change the <name>my-project-name</name> part of the pom

How do I associate my custom ANT builder with the project instead of the Eclipse workspace?

I'd like to associate some ANT targets with my project's build in Eclipse.
No problem, I create a custom ANT builder, specify targets to run, all is well.
But then I realize that the builder information is saved in the workspace instead of the project! Why is that, and how do I fix it?
The goal is that anyone who imports the project in a new Eclipse workspace can build it without adding the builder manually. This means that I should have the builder configuration under source control, which means it should belong to the project, not the per-user workspace.
Maybe I'm just missing something?
There is a bit of confusion, it seems, because builders look like launchers, but they are stored in a different directory. Simply creating the .settings dir and copying the xml doesn't help...
When I create the .externalToolBuilders directory under .settings and copy the launcher/builder there, I get this:
Solution:
I restarted from scratch, deleted the project-specific data in the workspace directory, but left the .settings dir in the project dir. Re-created the builder/launcher, and Eclipse automatically created it in the correct place, and also added it to source control.
Indeed, your launcher (Run/Debug launchers or External Builders launchers) are saved by default in the workspace.
<workspace>\myProject\.externalToolsBuilder)
You can move that directory (.externalToolsBuilder) manually in the .settings directory of your project.
And uncheck the option "Delete configurations when associated resource is deleted" as mentioned in this SO answer.
With a full refresh of the project (or even a delete, followed by a reimport), your local version of .externalToolsBuilder should be taken into account.
For the Debug/Run launchers (not your case), you also can (since Eclipse3.4) use one of the Import wizards:
File > Import
type launch configuration, and you can import said configuration directly within your project.