Eclipse Zone is brought to you in partnership with:

Tomas Kramar lives in Slovakia, where he works for a company developing software for a major local telecommunication provider. He is also a student at the Slovak University of Technology. Tomas has posted 6 posts at DZone. You can read more from them at their website. View Full User Profile

Create New Eclipse Workspace - With All Your Old Settings

06.30.2008
| 170589 views |
  • submit to reddit

It's all a matter of taste. Do you like to have just one workspace for all your projects, or do you prefer to have multiple separate workspaces?

Sure, the first way seems to be the official, supported. It should be easy to manage the workspace -- given the tools like working sets (and working set filters), mylyn and the ability to close projects.

But I still don't get it.

I hate when my workspace is overflowing with projects, I want to have as many workspaces as projects.

So I create new workspace and live happily ever after.

But wait -- all my settings are gone. All my carefully crafted custom templates, all my keybindings, my font settings, everything is gone.

It's all text, fortunately

Lucky us. All eclipse settings are saved as a plain text in the workspace directory. So if you want to create new workspace, but preserve your settings, I have two answers for you:

The short answer

All settings are stored in the .metadata/.plugins/org.eclipse.core.runtime/.settings directory. I mean -- all relevant settings. If you look into .metadata/.plugins directory there are many more directories with settings, but they are too project specific. I've walked trough these configuration files one by one, believe me, nothing useful lies hidden there.

So the short answer is: If you want to create a new eclipse workspace and preserve all your settings, simply copy the .metadata/.plugins/org.eclipse.core.runtime/.settings directory into your new workspace directory.

Do not copy other directories! There are project specific settings and since your old projects are left in your old workspace, the copied settings would not be valid and you would get some nasty exceptions at eclipse startup.

The long answer

Let the code do the talk for me.

I have created a (simple) shell script that automates new workspace creation. The downside is that it requires either a *nix shell or windows with cygwin. Nevertheless, you can always manually copy the .settings directory (see the short answer). The script has been tested by me, I and myself so it should work (most of the time).

To use it, save it somewhere, make it executable (chmod +x new-workspace.sh) and run it either in interactive mode

./new-workspace.sh -i

where it will ask you the details, or with paths to your workspaces (the new workspace directory will be created for you, just specify the path)

./new-workspace.sh old-workspace new-workspace 

The script will create new workspace directory and copy the relevant settings from your old workspace.

If it doesn't work for you, drop me a comment. Feel free to improve it.

Update: the pastebin page expired (although I'd swear I checked the keep forever option), so I moved the script over to github.

References
Published at DZone with permission of its author, Tomas Kramar. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

David Karr replied on Mon, 2008/06/30 - 11:35am

What risks are there when creating a new workspace with this that will be used with a different version of Eclipse than the original workspace?

Also now at Eclipse 3.4, there are now several different pieces that can be separately exported and imported in a new Eclipse 3.4 workspace, technically making this script less meaningful (although still a little more convenient).  It's also unfortunate that those several pieces that Eclipse 3.4 can export and import still have to be done in different places.

Tomas Kramar replied on Tue, 2008/07/01 - 1:10am

I am using my 3.3 Eclipse created workspaces with 3.4 without any problems. The worst thing that can happen is that you get an exception at startup, but nothing worse.

Exporting and importing settings was possible even with 3.3, but as you said, it had to be done in several different places, making it very inconvenient and time consuming.

Looking at my 3.4 workspace -- the .settings directory is still there, with all relevant files, so the script will work even with 3.4.

Max MacLeod replied on Tue, 2008/07/08 - 8:17am

Hi Tomas,

firsly thanks for the tip. I've been wondering how to do this for ages.

One problem though. I copied the file and then started Eclipse pointing to the new workspace. All the settings were there. However, all the original projects were included also, all in their original location.

Any ideas?

 

Thanks again,

Max

Tomas Kramar replied on Wed, 2008/07/09 - 1:26am

Hi Max,

thanks for your feedback.

I'm not sure what happened. Did the script copy all your old projects into new workspace (can you find the projects directories in the new workspace)? If not, then please send me a copy of the created workspace, I will have a look.

Either way, this will be better handled by email, so we do not spam here. You can find my address in the script.

Max MacLeod replied on Wed, 2008/07/09 - 5:26am in response to: Tomas Kramar

Hi All,

sorry I was being a numpty. I had my -data command line option still pointing to the old workspace. Corrected that and it now works a treat!

 

Kind regds,

Max 

Colin Tucker replied on Wed, 2008/07/09 - 1:25pm

I had some problems getting the script to work with cygwin after I saved the script in my editor with the default settings.  I got it working though, by saving the script in "Unicode - ASCII Escaped" with "UNIX line Terminators".

 

Thanks for posting - it was very helpful 

Tomas Kramar replied on Fri, 2008/07/11 - 12:37am

This way you will only copy your workbench layout, but not your settings -- as you said, you have to export and import your preferences. Using the script, or manually copying the settings folder will acomplish it for you in a few keystrokes and a fraction of time.

James Ervin replied on Mon, 2008/07/14 - 3:48pm

Can't you just export your preferences?  The 'File > Export > Preferences' menu item will create a .epf file somewhere that can be imported into Eclipse when you are pointing at your new workspace. 

 Still the idea of just copying one directory has its appeal, I will keep this one in mind for future reference.  Of course, I tend to do the whole one workspace to rule them all thing too.

Tomas Kramar replied on Tue, 2008/07/15 - 1:14am in response to: James Ervin

Thanks for the tip James, works great.

Max MacLeod replied on Tue, 2008/07/15 - 3:15am

James,

just looking at this. Export preferences looks like it just does keys and JREs. For things like external tools, launch configurations, plugins, etc., we need something a bit deeper.

 

Cheers,

Max 

James Ervin replied on Tue, 2008/07/15 - 1:05pm in response to: Max MacLeod

You are right Max that it does not do everything, but it does a little more than that.  It will preserve settings like key bindings and code formatters as well.  Still like I said, I will keep this little tidbit in mind the next time I create a new workspace, that is for sure.

Max MacLeod replied on Mon, 2008/08/04 - 4:38am in response to: Richard Hansen

Hi Richard,

I don't have that option. I'm on 3.2.2. Is it in a later release?


Cheers,

Max 

Michael Brehm replied on Wed, 2009/09/16 - 9:09am

Does this still work with Eclipse 3.5 (Galileo)?

Sanjay Rakholiya replied on Fri, 2009/10/23 - 5:03am in response to: Michael Brehm

Yes, Its working fine for Eclipse 3.5.

nick forder replied on Wed, 2010/06/16 - 4:57am

Cheers Thomas,

Copy paste works nicly for me in 3.5.1 in winows and Ubuntu Linux.

This feature has been forcing me to stay with one workspace too much, something I don't like after using IntelliJ for some time.

Thanks

Nick

 

Nicolas Conde replied on Tue, 2012/08/14 - 1:11pm

Very good information, i agree with James Ervin (replied on Mon, 2008/07/14 - 4:48pm)


Summarized and agrege important parts in Spanish on this link

http://java-white-box.blogspot.com.ar/2012/08/eclipse-como-importar-un-workspace-como.html

Thank you very much for illuminate our path.

João Antunes replied on Wed, 2012/10/24 - 8:41am

It works so good that I even registered on dzone (btw, lots of info required, jeez) to say:

 

thanks!

 

It's even nicely wrapped with a bash script!! 

João Antunes replied on Wed, 2012/10/24 - 8:51am in response to: João Antunes

Nevermind, I spoke too early, it doesn't copy the editor settings, with Juno at least.

 

But you can go to File > export > general > preferences - then save your preferences to a file and import them on the new workspace.

 

Anyway, I guess this was helpful before that was possible, so, thanks anyway. 

Stephanie Kaye Lopez replied on Wed, 2013/01/23 - 7:48am

 Workspace refers to small premises provided, often by local authorities or economic development agencies, to help new businesses to establish themselves. These typically provide not only physical space and utilities, but also administrative services and links to support and finance organisations, as well as peer support among the tenants. -The Balancing Act Lifetime

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.