45

When I copy an Eclipse project directory, it contains the .classpath and .project files so that when I take that same directory to another Eclipse instance, I don't have to setup my build path and such (assuming that all the resources are contained in the project, and not external.)

However, this procedure doesn't cause launch profiles to "travel" with the directory.

Is there some other file/directory structure I can "carry around" to another instance of Eclipse that will include my launch profiles?

Jared
  • 25,520
  • 24
  • 79
  • 114

6 Answers6

66

The .launch xml files (launcher definition) are found in

[eclipse-workspace]\.metadata\.plugins\org.eclipse.debug.core\.launches

Just copy them into your <project>/.settings directory.
Refresh your project, and there you have it: those launcher configuration are available, and you can copy them along the rest of your project files.

Warning: do uncheck the option "Delete configurations when associated resource is deleted" in the Run/Launching/Launch Configuration preference panel: it is common ot soft-delete a project in order to import it back again, to force a reinitialization of the eclipse metadata,... but this option, if checked, will removed your detailed launch parameters!

See also Which eclipse files belong under Version Control, and where are the external tools launch configurations in Eclipse.


Jared adds:

There is no .settings directory in my project directory - I created it and put the .launch file in there, refreshed my project, and it doesn't have any Run profiles. Do you have to mirror the directory structure under .metadata?

Just create the .settings directory (it is actually created when you have project specific settings as illustrated in the question "Maintaining a common set of Eclipse preferences").
Then delete the same .launch file from the .metadata directory.
Then refresh your project and go to the "Run Configurations" Panel: you will see your launch configurations still available, except they are stored where they belong: within your project directory and not buried under an obscure workspace metadata thingy.


Update June 2012

I always seen my launch configurations, saved under PROJECT_LOC/.settings, automatically imported when reloading the Eclipse workspace.
However, as described in "Tip: Creating and Sharing Launch Configurations (2007)", you should be able to reference a launch configuration saved into any subdirectory of your project if you go to the "Common" tab of your "Run Configurations" wizard.

shared file for launcher

So saving your launcher anywhere in the project won't display them automatically in the "Run Configurations" section of the preferences.
But declaring a new one, sharing its launcher as a "Shared file" (as illustrated above), and then overwriting that launcher with the actual one you had previously saved would update that run configuration.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • There is no .settings directory in my project directory - I created it and put the .launch file in there, refreshed my project, and it doesn't have any Run profiles. Do you have to mirror the directory structure under .metadata? – Jared Jun 04 '09 at 19:01
  • I actually still didn't get this to work....was actually working with two different workspaces, copying the launch file from the .metadata in one into the .settings in the other - couldn't ever get it to appear in the second. If I could get this to work, it's clearly the right way to do it. (the method of setting the profile to save in a shared location on the "common" tab did work for me.) – Jared Jun 05 '09 at 14:54
  • It does work in 3.5, but actually the "common" tab is a cleaner way to achieve the same effect, so you have chosen the best approach. Mine is for legacy launchers created under workspace .metadata: you can bring them back into your project that way. – VonC Jun 05 '09 at 15:21
  • VonC, I followed your suggestions but had problems when I import the project with a different name. I've even posted a new question: http://stackoverflow.com/questions/3444615/in-eclipse-how-to-have-launch-configurations-relative-to-the-project Maybe you can help me. – neves Aug 09 '10 at 22:31
  • Thanks. BTW, "Delete configurations when associated resource is deleted" seems to be unchecked by default in Juno (4.2). – Nick Westgate Mar 31 '13 at 11:22
  • The answer states this, but I'd like to emphasize, (since there are so many preference-like dialogs in eclipse) This is under *Run configurations*, not preferences or project preferences. – Joshua Goldberg May 08 '14 at 15:17
  • one extra step for me, make changes in a line inside .launch file **** – Srinath Ganesh Apr 01 '16 at 05:17
33

Try choosing a shared file location inside your workspace from the "Common" tab of the launch configurations (profiles).

Cagatay
  • 1,372
  • 1
  • 12
  • 16
4

Depending on the amount of moving around you do and the number locations you move to, storing your launch files in an online storage space and then setting up folders at the new locations to synchronize with it may be a viable solution.

Dropbox is a decent online storage system that gives users up to 2 gigabytes of storage.

Here is an example of how you can synchronize folders out side the Dropbox folder curtiousy of LifeHacker.com :

Use either the JUNCTION utility from Sysinternals, or the MKLINK command built in to Windows Vista and Server 2008, for example:

junction "C:\Documents and Settings\User\My Documents\My Dropbox\DesiredFolder" "C:\Path\To\DesiredFolder" mklink /D "C:\Users\Steve\Documents\Dropbox\DesiredFolder" "C:\Path\To\DesiredFolder"

Or, if you prefer a GUI, install Link Shell Extension.

[eclipse-workspace].metadata.plugins\org.eclipse.debug.core.launches would be the DesiredFolder.

You could also use SyncToy to echo changes from another folder to your Dropbox folder. This keeps 2 copies on disk though.

On OS X or Linux, try the following:

Use the ln command, for example:

ln -s /path/to/desired-folder ~/Dropbox/desired-folder

This works with files too:

ln -s /path/to/desired-file ~/Dropbox/desired-file

Another easy way to do this with Terminal is type the ln -s part, then from Finder drag the folder/file that you want into the Terminal window then drag the Dropbox folder and hit return.

Note that an Alias file or folder does not work.

Another solution could be to keep your launch files in an svn repository. Search for How to run Eclipse launch configurations programmatically? on this site. Sorry can only post one url so I used it on Dropbox.

mkamowski
  • 334
  • 2
  • 7
  • +1 for ingenious use of Dropbox (my favorite new app of the year.) I've got all my stuff under CM, so no need for me...but smart nonetheless. – Jared Jun 05 '09 at 14:52
2

There is an another clean way to share the launch configurations in Eclipse.

  1. Create a java project. For instance lets name it Launches-Configs.
  2. Now create a new Run Configuration for a project that you need to run.
  3. On the Run Configurations window navigate to Common tab. Ensure Shared File option is selected and input the Shared File location is set to \Launches-Configs\src
  4. Check in Launches-Configs to a VCS and share with other teams
    Run Configuration
Hari
  • 631
  • 7
  • 5
2

I have had good use of creating a /launch folder, and then setting the launch configuration to be "Shared file:" (the Commons panel) to the above mentioned launch folder.

The resulting launch file can be checked into e.g. CVS git and be pulled into a fresh workspace.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • Thanks for the hint with the CVS. I was going for a network drive, but putting it in the CVS has the additional charme of having it in sync with the code. – Stroboskop Jan 17 '12 at 13:23
0

Create a Launch Configuration with Shared File option selected under Common Tab. This will create a configuration file with .launch extension. Now in another workspace just go to Import and select Launch Configurations, choose the configurations from the directory and finish. It will appear in the Run configuration now.

Kajal
  • 206
  • 2
  • 8