39

Okay, so I made a mistake of setting my home directory (~, a.k.a. /home/user) to be my workspace location on my RHEL6 box.

I want to change my workspace to ~/workspace. However, I can't seem to do this by copying files. For some background, the project I am currently working on and have fully set up under the ~ workspace, has all source files stored elsewhere (~/depot/.../../../../src), so I don't even see a folder in ~ representing my project.

Kara
  • 6,115
  • 16
  • 50
  • 57
Amil
  • 609
  • 1
  • 5
  • 12

5 Answers5

63

Do the following steps:

  • close all the projects in workspace
  • close Eclipse
  • move the directory .metadata from ~ to ~/workspace
  • open Eclipse and when prompted for the workspace selection set it to ~/workspace
niculare
  • 3,629
  • 1
  • 25
  • 39
  • 16
    To prompt Eclipse for a workspace, in Preferences go to General -> Startup and Shutdown -> Workspaces. Check the box labelled "Prompt for workspace on startup". – EricRobertBrewer May 15 '13 at 19:00
  • 5
    I find this works if you want to move the WS (.metadata) and the projects to a new location, but if you just want to move the workspace then it doesn't really work: when you try to re-open the projects it can't find them because knows of their location relative to the workspace. I thought I could overcome this by setting the 'PARENT_LOC' for the workspace but that didn't help. – Tom Dec 20 '13 at 20:49
  • 3
    If you had previously selected your workspace (`~/old_workspace`) as the default, Eclipse will recreate it when it restarts. Either de-default it (follow @UberPrinny's instructions), or clean up afterwards. – offbyone Jan 23 '14 at 18:40
  • 1
    I have the impression this doesn't work anymore since Eclipse Oxygen (4.7), or is it just me? – zb226 Aug 02 '17 at 08:56
  • 2
    "You should not copy or move the workspace directory, because it may contain metadata with absolute file system paths, which will be invalid if the workspace is copied elsewhere." Source:[Oxygen (4.7) User Guide](https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-2.htm) – David Balažic Apr 12 '19 at 14:29
17

On Windows 8 I did this:

  1. Closed All of the projects in Eclipse
  2. Closed Eclipse
  3. Physically moved the workspace folder to a new location (in my case I put it into c:\projects as I have this backed up).
  4. Started Eclipse
  5. File > Switch Workspace and selected the new path. Then eclipse restarted itself and all projects showed up.
Svetoslav Marinov
  • 1,498
  • 14
  • 11
  • 1
    Did the same on Windows Server 2012. This is similar to the accepted answer except it refers to moving a .metadata folder which is already inside my workspace folder, and I wanted to just move the workspace folder. – Daniel Widdis Apr 24 '15 at 19:10
3

After closing Eclipse projects and Eclipse itself, move all project folders and .metadata folder in the new workspace folder.

Nendrel
  • 83
  • 6
2
  1. Close Eclipse.
  2. Open the location of the workspace and cut paste the entire directory (which contains the ".metadata" directory into the intended location.
  3. Restart Eclipse with newly copied folder as the workspace (parent directory of ".metadata" folder).
faintsignal
  • 1,828
  • 3
  • 22
  • 30
Guru
  • 2,739
  • 1
  • 25
  • 27
  • This is not a resilient technique if you wish to keep your java projects separate from your workspace. For example, what if you wanted (or needed) to leave your projects where they are and only move your workspace? You cannot use this technique to do so. The best way is to close Eclipse and physically only move the hidden .metadata directory to where you want it to be. That way only your workspace is migrated leaving your projects at their original locations. However, your method is OK if you are fine with migrating your projects with the workspace. Hope that made sense. – IqbalHamid Jul 20 '18 at 12:00
  • Actually, if the .location file holds the full path of your project, one would think it would be worse to move the project folder since the workspace will no longer be able to find it. – rougou Jul 23 '19 at 01:01
  • It seems if you add the project to the workspace folder, no .location file is created and it is assumed to be relative. So if the projects are in the workspace folder, most likely you have to move them with the .metadata folder. – rougou Jul 23 '19 at 01:39
  • Just to be clear, in step 3 you could use the -data parameter in your shortcut to specify the new workspace location, or go to File->Switch Workspace after restarting eclipse. But with the latter, Eclipse will have already created a new .metadata folder in the original location on startup (you can safely delete this folder). – rougou Jul 23 '19 at 01:44
0

I was testing to move files manually from workspace and suddenly my eclipse did not show them in my eclipse view so i moved them back to the same location where they have come from, entered eclipse and clicked right click on the package where i am expecting those files and clicked Refresh, Now i can view them on my Eclipse under packages, so try do refreshing it might work for u.