Eclipse changing workspace and directory
Asked Answered
T

4

11

I am not that used to changing workspaces in Eclipse, in fact, I only have one workspace. But right now, there is a need to change workspace and organize different projects but I don't know how to do it.

I saw something about refactoring and simply importing projects but I don't want the outcome of that.

Currently, I have C:\Users\krato\workspace\ as my default workspace and I want to create another in D:\dev\. So I created one using File > Switch workspace > other > D:\dev\. And in that workspace I imported some projects from the prevoius workspace. Yes I already see the projects in the dev workspace but when I open the other workspace (C:) I still see the imported projects and the folder (C:...\workspace) still contains the projects. What I want to do is to transfer the projects in a different workspace and in a different folder, which in my case D:\dev.

I tried to refactor but it says that it overlaps with the workspace location.

Please suggest the best way to do this.

I would also like to ask your recommendations whether I should have a same workspace and projects folder (like what I want to do) or different directories for my workspace and projects folder.

Tegucigalpa answered 12/2, 2014 at 2:50 Comment(1)
"Import" copies, if anything, it does not move.Cargill
K
9

Your project folders don't need to be where your Eclipse workspace is. In fact, I would recommend to keep them separate:

  • Your project folders contain the project's code, together with Eclipse .project and .classpath files.
  • Your workspace on the other side contains Eclipse settings for working with your projects. It can contain multiple projects, and a project can be contained in multiple workspaces.

In your example, I would recommend to manually copy or move your code to D:\Dev, create a new workspace in C:\Users\krato, e.g. C:\Users\krato\workspace-dev, and then import your projects there using Import existing projects.

I would recommend moving rather than copying. If you really need a second copy of your project, consider using a version control system such as git and create a branch instead.

Kizzykjersti answered 16/2, 2014 at 10:26 Comment(4)
Yes I really want to move and not to copy but I messed up with the imports. How would I move to D:\Dev my current projects in C:\Users\krato\workspace?Tegucigalpa
Also, how can I do it in such a way that my workspace is similar to my projects folder.Tegucigalpa
Just find your project folders under C:\Users\krato\workspace and drag / drop them to D:\Dev. After moving, if you still need your original workspace, you'll have to delete your projects and reimport them there. The project structure in your workspace will always reflect your projects content.Kizzykjersti
it does not work, i tried it, it generates a workspace with blank projects but blank contentsTegucigalpa
E
7

To achieve what you want, you need to do the following:

  1. Create a new Eclipse workspace (like you have done already)
  2. Import the projects you want to move using File/Import/General/Existing Projects and select the check box "copy projects into workspace"
  3. Delete the now copied projects from the original workspace in Eclipse and select the check box "delete project contents on disk"

After that you will have completely moved the projects from one workspace to another, including the underlying folders.

I would also like to ask your recommendations whether I should have a same workspace and projects folder(like what I want to do) or different directories for my workspace and projects folder.

It depends on your own preferences and, how the projects are going to be used. I prefer to have my main project folders separate from my workspaces, because some of them will reside on either SVN, GIT or also Dropbox. Especially library projects, that might be used by more than one other projects, are better kept in a separate workspace and/or folder. This allows one to keep the overview and one can simply include these library projects in other workspaces when needed.

Episiotomy answered 19/2, 2014 at 9:3 Comment(0)
S
0

If you didn't delete the projects from the first workspace, they will still be there. Did you copy the files from C: to D: or move them? If you copied them to D: and you don't want them on C:, delete them from C:. But make sure they really are on D: first.

Or am I totally misinterpreting your question?

Silesia answered 12/2, 2014 at 3:25 Comment(2)
Yes I can do that but is that the best way?Tegucigalpa
It depends on your goal. If you want some of the project from D: to stay on D: and some to move to C:, I guess this works about as good as any other option.Silesia
G
0

I believe I had a related problem, and conquered it.

I needed to move my entire workspace (containing my project directories) to a different drive, on Windows. If one wanted to move only some projects, and keep the old workspace as well, this could be modified simply by deleting projects as desired.

On http://www.eclipse.org/forums/index.php/t/248863/ nwbeeson had written:

Thank you. Here is exactly how to do this from a friend who is an Eclipse expert. 1. Open Eclipse and switch to Workspace1 using Switch To Workspace... 2. Check the projects in Workspace1 3. Switch to another workspace to make sure that Workspace1 is closed completely by Eclipse (Critical step!) 4. Quit Eclipse 5. Copy Workspace1 and name the copy Workspace2 6. Copy Workspace2 to a USB flash drive 7. Copy Workspace2 from the USB flash drive onto the hard disk of a different computer 8. Open Eclipse on the new computer 9. Switch to Workspace2 using Switch To Workspace...

The projects open normally from Eclipse on any machine as though that workspace had been there all along. The critical step seems to be switching to another workspace before quitting Eclipse. If you skip that step the copied and transferred workspace does not open correctly.

This worked perfectly. Without the critical step, Eclipse balked at the new workspace location. All sorts of references to old paths are used, and apparently updated only if the workspace was fully doubly hyperbolically closed prior to the copying of the workspace to a new location.

Glinys answered 8/9, 2015 at 17:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.