Passing parameters to Eclipse RCP via the command line

less than 1 minute read

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++;