71

A project has moved to a different location, so Eclipse won't open the project. You'll immediately think about simply changing the pointer to the location, but in Eclipse they try to make this impossible for some reason.

You cannot change the project location in the Project Explorer properties.

You can go to [workspace]/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/ProjectName and try to edit .location which is the pointer to the project, but this file is purposely stored in binary.

How do I change this .location, is there a tool for that? Any other way to simply point my old project entry to it's new location?

tim-kt
  • 304
  • 5
  • 17
Redsandro
  • 11,060
  • 13
  • 76
  • 106
  • Possible duplicate of [Eclipse change project files location](https://stackoverflow.com/questions/1430836/eclipse-change-project-files-location) – kerner1000 Jan 03 '18 at 10:49

11 Answers11

109

Delete the project from eclipse.

ENSURE THAT THE CHECK BOX is UNSELECTED, during this delete

And then import the project by File -> Import -> Import existing project and choose it from the new location.

Don't try to modify the eclipse files manually!

Siddharth
  • 9,349
  • 16
  • 86
  • 148
Kai
  • 38,985
  • 14
  • 88
  • 103
  • 1
    Aren't my project specific settings in my workspace, and thus lost, when I delete the project? – Redsandro May 25 '13 at 00:09
  • 10
    IMPORTANT: when you delete the project, say "no" to "Delete the project on disk". It then just removes it from your workspace. – Francis Upton IV May 25 '13 at 04:17
  • 3
    @Redsandro project specific settings are stored in the project not in the workspace. When you re-import the project the settings should be the same. If you are in doubt make a backup of your workspace and just try it. Francis since the project was moved this should be irrelevant but to be absolutely sure you are right. – Kai May 25 '13 at 05:07
  • Bold **Don't** helps you save a ton of problems, I had to learn the hard way. Thank you Mr. Proctor :D – Alan May 18 '16 at 08:16
  • [Instructions for how to "delete the project from Eclipse"](http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-42b.htm) -- for Kepler, but it's still applicable – faintsignal Jul 24 '17 at 20:41
  • This answer needs to be enhanced to explain any side effects of doing things this way. Is there any impact to the project settings? Mylyn tasks? So many potential questions – Robert Aug 29 '19 at 11:58
31

Much simpler:

Right click -> Refactor -> Move

VXp
  • 11,598
  • 6
  • 31
  • 46
kerner1000
  • 3,382
  • 1
  • 37
  • 57
  • @slaadvak Right click the project in Package Manager and see "Refactor (Alt+Shift+T)" in the 4th section from the top below "Build Path" and "Source" entries. – Dan Dar3 Nov 06 '15 at 22:14
  • 10
    This command is great to move projects that are in the place on disk that eclipse expects; however if the code has been moved (as the question suggests) you can't use this technique, you need to use the answer provided by @kai ; delete the project and re-import from the new location. – thetoolman Apr 18 '16 at 09:56
  • This is only useful answer – Gajotres Jan 04 '17 at 15:02
  • 1
    If you have already moved the project. You can make symlink to the new location from the old location. Thus, eclipse can find it in both locations order to initiate the refactor->move. This worked for me. – dave May 26 '17 at 15:21
  • This option does not exist in Eclipse Juno – Radon8472 Feb 06 '18 at 18:25
  • @Radon8472 The refactor option should exist, but you have to use the "package explorer" rather than the "project explorer" to see it. – Boann Sep 19 '18 at 21:44
  • In Eclipse Oxygen worked both in "package explorer" and "project explorer". – Douglas Gardim Mar 26 '19 at 14:03
  • In Eclipse 2019-06, this seems to work from Package Explorer for any project, and from Project Explorer only for some project types (at least Java projects). – Toper Feb 05 '20 at 14:51
19

You can go to [workspace]/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/ProjectName and try to edit .location which is the pointer to the project, but this file is purposely stored in binary. You Should Edit the location in file and some binary data ] the binary data that should edit , is bold :

40 B1 8B 81 23 BC 00 14 1A 25 96 E7 A3 93 BE 1E 00 5D 55 52 49 2F 2F 66 69 6C 65 3A 2F 44 3A 2F 6D 61 64 64 61 68 2F 50 72 6F 6A 65 63 74 73 2F 46 6C 65 65 74 4D 61 6E 61 67 65 6D 65 6E 74 2F 54 79 70 65 73 2F 50 6F 72 74 61 62 6C 65 63 6F 64 65 2F 46 69 72 6D 77 61 72 65 2F 74 65 73 74 2F 43 50 50 2F 41 54 6D 65 61 67 38 4C 69 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C0 58 FB F3 23 BC 00 14 1A 51 F3 8C 7B BB 77 C6

The Location of 0x11 of file, is the length of file name, that you should edit it. its value is the length of highlighted part

Also You Can Use ProjectLocationUpdater : https://marketplace.eclipse.org/content/projectlocationupdater/metrics

  • 3
    ProjectLocationUpdate worked like a charm! And it works on multiple projects. – gnom1gnom Mar 03 '16 at 15:34
  • 1
    ProjectLocationUpdater worked like a charm. We had had only one extra step to complete before: since we were moving to different computer without same disk layouts, we had to move to another drive+location (from `D:` to `C:\dev`): we had to mount the old folder location to let eclipse find the old files using `subst D: C:\dev`. (On Linux/Max, a symlink would have done the trick) – Jidehem Oct 12 '17 at 09:06
  • The correct answer should not be "edit the binary data"! Right-click, Refactor --> Move... is the correct answer. – David Koelle Jun 11 '19 at 22:09
  • I had to update over a dozen projects when I switched from a PC to a Mac... ProjectLocationUpdater did that with only a few clicks! Awesome! – Veloz Feb 10 '20 at 21:57
  • ProjectLocationUpdate , great advice ;-) – Marti Pàmies Solà Sep 07 '20 at 12:37
2

I realise this is an old post however I thought I would add my own resolution to the same issue. I had imported a number of projects into my workspace from another machine. However the resource files would not build because for some reason Eclipse had marked the location of the projects incorrectly (using a mapped path instead of a unc path). This meant that each time I tried to reference libraries within the workspace they would tick green, then go red and fail. Despite the fact the libraries and the project where in the same workspace and I had followed the correct procedure for importing the projects.

As the OP mentions under properties there is a project location path. I noticed that the project location was different but for some bizarre reason Eclipse (in their almighty wisdom) do not allow you to reselect or change the path. In fact even trying the refactor->move fails because the project is already inside the workspace (never heard of generating a temp folder for moves?).

However I did notice after looking at the file structure of the imported projects that Eclipse had added a .location file (mentioned above) which was actually absent from all other projects in the workspace. So I deleted the .location file, reopened eclipse and sure enough the projects build properly.

So after wasting a few hours on something as silly as this I am now able to work and hopefully this might save you some trouble too.

David Hirst
  • 1,890
  • 2
  • 22
  • 31
2

Summary of what worked for me (Extracted from other answers and comments)

  1. (Only required if you have already moved the project)

    make symlink to the new location from the old location.

  2. Regardless of the type of project (Java, Python, etc.)

    • Open view Package Explorer (Window -> Show View -> Other -> Java -> Package Explorer)
    • Right click -> Refactor -> Move (in the relevant project within that Package Explorer)
    • Select new location
  3. (If a symlink was created)

    Delete symlink if one was created in step 1

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
Jorge Moraleda
  • 362
  • 3
  • 8
1

You can change the .location file using a hex editor. However, you cannot simply replace the file location string stored there by the new one. You also have to edit the preceding byte defining its length (in bytes) accordingly. You may then re-open the project in Eclipse.

bsumirak
  • 201
  • 2
  • 4
1

I was working in PyDev (python) and this refactor option was not available. I had to switch to the Java Package Manager to accomplish this. After doing that, I switched back to PyDev.

demongolem
  • 9,474
  • 36
  • 90
  • 105
0

It is not advisable to change the .location file. The eclipse project list will be destroyed if you manually edit the .location file. I lost all the projects after modifying the file.

cja
  • 9,512
  • 21
  • 75
  • 129
jaogoy
  • 81
  • 1
  • 2
0

Admittedly, this is a dated post, but I wanted to mention that I faced this same issue using Spring Tool Suite 3.9.7 when I was pushing my project to a new Github repo and something went terribly awry. As a result, I could not run my application locally anymore and had to revert the project location. I had read horror stories about git deleting project files, so I did some research. For the most part, I went with the answer of @kerner1000 above, but with an important addition. Please see below steps and explanation.

  • Rt. click on the project
  • select "Refactor"
  • select "Move..."
  • Check the checkbox for, "Use default location"

Note: I tried at first to copy/paste in the path to relocate the project to, but Eclipse gave me an over-write error. So checking the checkbox made the difference.

reverb1010
  • 41
  • 1
  • 8
0

In eclipse, Version: 2020-03 (4.15.0), you can do that:

  1. Over the name of project, right click.
  2. Select Refactor
  3. Rename.
  4. Indicate the empty folder that will contain the moved source

enter image description here

-3

Try this. Open eclipse --> Go to File --> switch workspace --> other --> choose your workspace by clicking the Browse button. Hope this will work.

Waseem
  • 123
  • 1
  • 1
  • 11