Eclipse changing workspace and directory

41,426

Solution 1

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.

Solution 2

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.

Share:
41,426
krato
Author by

krato

Apparently, this user prefers to keep an air of mystery around them to produce lift.

Updated on July 11, 2022

Comments

  • krato
    krato almost 2 years

    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.

  • krato
    krato over 10 years
    Yes I can do that but is that the best way?
  • krato
    krato over 10 years
    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?
  • krato
    krato over 10 years
    Also, how can I do it in such a way that my workspace is similar to my projects folder.
  • stoyanr
    stoyanr over 10 years
    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.
  • krato
    krato over 10 years
    it does not work, i tried it, it generates a workspace with blank projects but blank contents
  • ferzle
    ferzle over 10 years
    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.