Eclipse changing workspace and directory

krato picture krato · Feb 12, 2014 · Viewed 40.3k times · Source

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.

Answer

stoyanr picture stoyanr · Feb 16, 2014

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.