Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Accessing startup parameters
Accessing startup parameters [message #1066803] Thu, 04 July 2013 09:15 Go to next message
Urs Beeli is currently offline Urs Beeli
Messages: 302
Registered: October 2012
Location: Bern, Switzerland
Senior Member
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 #1066830 is a reply to message #1066803] Thu, 04 July 2013 10:39 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 529
Registered: October 2011
Senior Member
I did not try or verify this:

I think that it works like the parameters included in config.ini

If you add this as parameter:

 -Dparam=value


You can access it with:

Activator.getDefault().getBundle().getBundleContext().getProperty("param");

[Updated on: Thu, 04 July 2013 10:44]

Report message to a moderator

Re: Accessing startup parameters [message #1067251 is a reply to message #1066830] Mon, 08 July 2013 02:10 Go to previous messageGo to next message
Urs Beeli is currently offline Urs Beeli
Messages: 302
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Thanks for your answer, however it does not seem to work:

I have added the following to my run configuration:
 -Dusername=user1 -Dpassword=pass1

index.php/fa/15499/0/

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 144 times)
Re: Accessing startup parameters [message #1067496 is a reply to message #1067251] Tue, 09 July 2013 02:11 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 529
Registered: October 2011
Senior Member
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 04:20 Go to previous messageGo to next message
Urs Beeli is currently offline Urs Beeli
Messages: 302
Registered: October 2012
Location: Bern, Switzerland
Senior Member
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 04:35 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 529
Registered: October 2011
Senior Member
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.
Re: Accessing startup parameters [message #1067542 is a reply to message #1067525] Tue, 09 July 2013 05:22 Go to previous message
Urs Beeli is currently offline Urs Beeli
Messages: 302
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Jeremie Bresson wrote on Tue, 09 July 2013 10:35
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.


Thanks, I hadn't realised that RCP already provided a mechanism for that. Using
Platform.getCommandLineArgs()

works perfectly.
Previous Topic:Scout Book: Can't access the org.scribe plugin in the server
Next Topic:Info-Field inside a form
Goto Forum:
  


Current Time: Thu Apr 17 03:48:50 EDT 2014

Powered by FUDForum. Page generated in 0.02856 seconds