Managing Eclipse RCP Launch Arguments
Join the DZone community and get the full member experience.
Join For Freein my last post i discussed how to best manage run configurations for eclipse rcp applications . but there was one related topic i wanted to discuss in more detail, and that is how to manage launch arguments.
what are launch arguments?
launch arguments are arguments that are added to the command line when you execute your application. these arguments come in two flavors:
- program arguments – arguments that are eclipse-specific. for example, the -clean argument will clear the configuration area on startup.
- vm arguments – arguments that make sense to the java vm. for example, the -xmx argument allows you to set the maximum heap size for the vm.
both of these argument types can be set on the
arguments
tab in the run configurations dialog.
launch arguments and the target platform
we oftentimes want to apply the same launch arguments to all of our
run configurations, and one way to handle that is to specify them on
your
target platform
. on the
target platform
preference page there is a section where you can add whatever arguments you wish.
the arguments associated with a target platform will be added to run configurations
generated from the manifest editor
. they will
not
be added to configurations generated by the product configuration
editor. also, because the manifest editor link does not regenerate a
configuration each time, you will need to explicitly delete a
configuration if you want to recreate it using new target platform
arguments.
launch arguments and products
a second way to manage arguments is to add them using the
launching
tab of the product configuration editor.
when you add arguments in this way, two things will happen:
- the arguments will be added to your run configurations if you launch using the link in the product configuration editor . because this link regenerates the run configuration each time, consistent use of the link guarantees that your configuration is in synch with your product definition.
- the arguments will also be added to your deployed application in the form of an ini file. this is a nice feature, but it means that you need to be careful when adding arguments that are only useful during development. for example, you may want to use -clean to clear the configuration area when you’re developing, but you probably do not want to ship this argument to your customers.
launch arguments best practices
my approach is to add arguments using the product configuration editor and to always launch my applications using the link in that editor. this guarantees that my run configurations are always in synch with my product definition. i also take care to not add arguments that would be detrimental to a deployed application. some, such as -consolelog, i consider harmless in a deployed app and i just leave those in.
if for some reason i absolutely have to add an argument that should not be deployed, i usually clean it out of the ini file during the build process. it’s pretty rare for me to have to do this, though.
Opinions expressed by DZone contributors are their own.
Comments