Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Accessing startup parameters
Accessing startup parameters [message #1066803] Thu, 04 July 2013 13:15 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
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 14:39 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
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 14:44]

Report message to a moderator

Re: Accessing startup parameters [message #1067251 is a reply to message #1066830] Mon, 08 July 2013 06:10 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
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 515 times)
Re: Accessing startup parameters [message #1067496 is a reply to message #1067251] Tue, 09 July 2013 06:11 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
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 08:20 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
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 08:35 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
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 09:22 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
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 25 03:37:49 GMT 2024

Powered by FUDForum. Page generated in 0.03899 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top