Passing parameters to Eclipse RCP via the command line

It is easy to pass parameters via the command line to an Eclipse RCP application. For example the following checks the command line arguments for the dbconnection and configures then the DBObject with the right values.


String[] args = Platform.getCommandLineArgs();

int i = 0;
while (i < args.length)
{
if (args[i].equals("-dbconnection"))
{
i++;
dao.setDbname(args[i]);
}
if (args[i].equals("-dbuser"))
{
i++;
dao.setDbUser(args[i]);
}
if (args[i].equals("-dbpassword"))
{
i++;
dao.setDbPassword(args[i]);
}
i++;
}

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of vogella.com. With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Uncategorized. Bookmark the permalink.