score:75

Accepted answer

you can copy your .classpath and .project files to the root of the new project directory and then choose 'import...' from the file menu, and select 'general/existing projects into workspace.' in the resulting dialog, locate the root of the new project directory and finish. make sure that you have deleted the old project from the work space before importing.

score:0

using neon - just happened to me too. you would have to delete the eclipse version (not from disk) in your project explorer and import the projects as existing projects. of course, ensure that the project folders as a whole were moved and that the eclipse meta files are still there as mentioned by @koenpeters.

refactor does not handle this.

score:1

if you have your project saved as a local copy of a repository, it may be better to import from git. select local, and then browse to your git repository folder. that worked better for me than importing it as an existing project. attempting the latter did not allow me to "finish".

score:1

i moved my default git repository folder and therefore had the same problem. i wrote my own class to manage eclipse location and used it to change the location file.

        file locationfile 
            = new file("<workspace>"
                    +"/.metadata/.plugins/org.eclipse.core.resources/.projects/"
                    +"<project>/"
                    +".location");

        byte data[] = files.readallbytes(locationfile.topath());

        eclipselocation eclipselocation = new eclipselocation(data);

        eclipselocation.changeuri("<new path to project>");

        byte newdata[] = eclipselocation.getdata();

        files.write(locationfile.topath(),newdata);

here my eclipselocation class:

public class eclipselocation {

    private byte[] data;
    private int length;
    private string uri;


    public eclipselocation(byte[] data) {
        init(data);
    }

    public string geturi() {
        return uri;
    }

    public byte[] getdata() {
        return data;
    }


    private void init(byte[] data) {

        this.data = data;   
        this.length = (data[16] * 256) + data[17];
        this.uri = new string(data,18,length);  
    }


    public void changeuri(string newuri) {

        int newlength = newuri.length();
        byte[] newdata = new byte[data.length + newlength - length];        


        int y = 0;
        int x = 0;

        //header
        while(y < 16) newdata[y++] = data[x++];

        //length
        newdata[16] = (byte) (newlength / 256);
        newdata[17] = (byte) (newlength % 256);

        y += 2;
        x += 2;

        //uri
        for(int i = 0;i < newlength;i++)
        {
            newdata[y++] = (byte) newuri.charat(i);
        }
        x += length;

        //footer
        while(y < newdata.length) newdata[y++] = data[x++];

        if(y != newdata.length)
            throw new indexoutofboundsexception();

        if(x != data.length)
            throw new indexoutofboundsexception();

        init(newdata);
    }


}

score:11

there is now a plugin (since end of 2012) that can take care of this: gensth/projectlocationupdater on github.

score:23

this link shows how to edit the eclipse workspace metadata to update the project's location manually, useful if the location has already changed or you have a lot of projects to move and don't want to do several clicks and waits for each one: https://web.archive.org/web/20160421171614/http://www.joeflash.ca/blog/2008/11/moving-a-fb-workspace-update.html

score:34

much more simple: right click -> refactor -> move.


Related Query

More Query from same tag