Saturday, June 12, 2010

Changing Eclipse RCP application workspace

We are developing an Eclipse RCP application and we wanted the default location of workspace to be under user's home directory and not under current directory (which is the default). By googling, I found that I can use -data program argument. But, when I put that option in .ini file it did not work. Some posts said that I should put the path argument after data in double quotes for it to work. But, that is not true either.

Finally, it turned out that I should specify the path in the next line after -data. Specifying the path in next line is the key here. So, in your application .ini file, it should look like:

-data
C:\MyAppWorkspace

Also, make sure that this (or any other program argument) appear before vm arguments.

But, we did not want to hardcode the path and instead wanted to point it to users home directory. For this, you could use:

-data
@user.home/MyAppWorkspace

This program argument can also be supplied as command line parameter. For example, eclipse.exe -data @user.home/MyAppWorkspace would work. Also, this could be supplied in the shortcut target in windows, if the application needs to be launched using double click.

In your RCP application, you can just specify these program arguments in "Launching" tab in your application .product editor. When you export your product, it will put the appropriate entry in your application .ini file.

6 comments:

shahid shaikh said...

can u just help me setting up hibernate in eclipse & get the simple program done in struts 2


Thanks.

lumo said...

i tried this one and noticed that there is a .metadata folder in the new location BUT the RCP does NOT load the stored settings correct... actually it simply creates the default every time i start it up (works fine if i do not modify the path...) any ideas?

Raja said...

@lumo - Can you add comment on what lines you added to which file?

Try adding the following to the beginning of your .ini file:

-data
@user.home/MyAppWorkspace

lumo said...

i am running a product from workspace (i do not build an export yet, therefore i have no ini file.

therefore i simply changed the run configuration (afaik this is the same as the ini file) and added those program arguments:

-data @user.home/MyApplicationName

further i tried to change the working directory (same tab on run configuration > arguments)

${system_property:user.home}/MyApplicationName

in both cases the working directory is changed and correct, BUT it does not save the changed layouts as mentioned above

Anonymous said...

Thanks for this! Adding `-data @user.home/...` to my product's Launching Arguments worked exactly as expected. One can confirm it by using the product export wizard and then running the result.

Unknown said...

Thank you for sharing very informatics and useful post about very useful info.... Turbo-IVP (Invoice Validation Portal) and Turbo eSigner