Accessing startup parameters [message #1066803] |
Thu, 04 July 2013 13:15  |
Eclipse User |
|
|
|
If I wanted to pass additional command line parameters to my scout client at start up, how would I access them later on (either in the client or the swt plugin)?
|
|
|
|
Re: Accessing startup parameters [message #1067251 is a reply to message #1066830] |
Mon, 08 July 2013 06:10   |
Eclipse User |
|
|
|
Thanks for your answer, however it does not seem to work:
I have added the following to my run configuration:
-Dusername=user1 -Dpassword=pass1

And then I have added
System.out.println("<swt/client>: username property: " + Activator.getDefault().getBundle().getBundleContext().getProperty("username"));
System.out.println("<swt/client>: password property: " + Activator.getDefault().getBundle().getBundleContext().getProperty("password"));
to both ExtendedNetAuthenticator.ExtendedNetAuthenticator() and Desktop.initConfig().
However, the output is null in both cases:
swt: username property: null
swt: password property: null
client: username property: null
client: password property: null
Am I missing something? Or does this not work at all? If so, what alternatives would I have to access either a param defined using -Dparam=value (or the others passed on the command line without the -D)?
Attachment: config.png
(Size: 131.39KB, Downloaded 564 times)
|
|
|
Re: Accessing startup parameters [message #1067496 is a reply to message #1067251] |
Tue, 09 July 2013 06:11   |
Eclipse User |
|
|
|
Just put your arguments as "VM arguments" instead of "Program arguments" and it will work.
I am not sure how the arguments that are defined in "Program argument" are handled in eclipse. In a JavaSE project those will be passed to the main(String[]) method.
|
|
|
Re: Accessing startup parameters [message #1067519 is a reply to message #1067496] |
Tue, 09 July 2013 08:20   |
Eclipse User |
|
|
|
Thanks Jeremie
When I put my arguments into "VM arguments" instead of the program arguments I can indeed access them the way you described. However, this seems a bit like a hack.
I realise that program arguments are passed to the string array in main(), I thought that maybe the client would make these parameters available to the client plugins in some way. I take it, that this is not the case? Ideally I am looking for a way to get access to all arguments passed to main() without having to know their names from within the client and renderer plugins.
|
|
|
Re: Accessing startup parameters [message #1067525 is a reply to message #1067519] |
Tue, 09 July 2013 08:35   |
Eclipse User |
|
|
|
Urs Beeli wrote on Tue, 09 July 2013 10:20
When I put my arguments into "VM arguments" instead of the program arguments I can indeed access them the way you described. However, this seems a bit like a hack.
I use it in my project (the parameters are defined the <app>.ini) file. This is pretty much the same as defining parameters in the configuration/config.ini file.
Urs Beeli wrote on Tue, 09 July 2013 10:20
I realise that program arguments are passed to the string array in main(), I thought that maybe the client would make these parameters available to the client plugins in some way. I take it, that this is not the case? Ideally I am looking for a way to get access to all arguments passed to main() without having to know their names from within the client and renderer plugins.
I think this is an Eclipse Platform question.
First result (using google):
Passing parameters to Eclipse RCP via the command line
Maybe you can give it a try.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04602 seconds