How can I change a project's location pointer in Eclipse?

EclipseDirectoryLocationProjectTarget

Eclipse Problem Overview


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?

Eclipse Solutions


Solution 1 - Eclipse

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!

Solution 2 - Eclipse

Much more simple:

> Right click -> Refactor -> Move

.

Solution 3 - Eclipse

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

Solution 4 - Eclipse

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.

Solution 5 - Eclipse

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.

Solution 6 - Eclipse

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.

Solution 7 - Eclipse

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

Solution 8 - Eclipse

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.

Solution 9 - Eclipse

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.

Solution 10 - Eclipse

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

Solution 11 - Eclipse

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRedsandroView Question on Stackoverflow
Solution 1 - EclipseKaiView Answer on Stackoverflow
Solution 2 - Eclipsekerner1000View Answer on Stackoverflow
Solution 3 - Eclipsehamidreza maddahView Answer on Stackoverflow
Solution 4 - EclipseDavid HirstView Answer on Stackoverflow
Solution 5 - EclipsebsumirakView Answer on Stackoverflow
Solution 6 - EclipsedemongolemView Answer on Stackoverflow
Solution 7 - EclipseJorge MoraledaView Answer on Stackoverflow
Solution 8 - EclipsejaogoyView Answer on Stackoverflow
Solution 9 - Eclipsereverb1010View Answer on Stackoverflow
Solution 10 - EclipseJoaquinFigueroaView Answer on Stackoverflow
Solution 11 - EclipseWaseemView Answer on Stackoverflow