You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by Krzysztof Harpula <kr...@superfund.com> on 2015/07/22 15:47:04 UTC

Using Ivy launcher, passing arguments to launched class.

Hello,

I have the following problem:

I want to launch my main class using Ivy launcher as documented in Ivy
manuals:

java -jar ivy.jar -main com.my.MainClass


My main class  expects parameters from command line in the format:
-paramName:paramValue

I try using Ivy launcher with -args option which is documented as follows:

-args <args> the arguments to give to the launched process


java -jar ivy.jar -main com.my.MainClass -args -param1:val1


However Ivy is not able to pass such a parameter into my class as it
interprets it as Ivy parameter which is not recognized printing: 
Unrecognized option: -param1:val1. (message from Ivy launcher)

So if I try what follows (remove "-" from my parameter):

java -jar ivy.jar -main com.my.MainClass -args param1:val1


Ivy passes param1:val1 as argument to my main however my application
does not recognize it as it expects its all parameters to start with "-"
just as Ivy launcher does.

I think this is either a *BUG* or I am missing something. It seems Ivy
launcher interprets  values after -args beginning with "-" as another
Ivy parameters. Is any way to pass parameters starting with "-" to the
launched class? Please help.

Best regards.




Re: Using Ivy launcher, passing arguments to launched class.

Posted by Jaikiran Pai <ja...@gmail.com>.
Looking at the code, it does appear that this case hasn't been handled. 
I am not part of the Ivy dev team so I can't say whether this is a bug 
or whether this was never thought of as a usecase. Perhaps you could 
wait for someone from the dev team to respond or maybe file an enhancement.

-Jaikiran
On Thursday 23 July 2015 05:50 PM, Krzysztof Harpula wrote:
> Yes I tried in double and single quotes.  The effect is that theses
> quotes are passed as part of command line arguments to  launched class
> so without modification of launched class to strip off theses quotes it
> still does not work. I think it is a common case that applications have
> parameters starting with "-" and not expecting quotes in values of
> command line arguments. It looks to be a bug in Ivy. So far I have no
> work around to it.
>
> Regards.
>
>
>
> On 2015-07-23 14:14, Jaikiran Pai wrote:
>> Have you tried to enclose those parameters in double quotes:
>>
>> java -jar ivy.jar -main com.my.MainClass -args "-param1:val1
>> -param2:val2"
>>
>> -Jaikiran
>>
>>
>>
>> On Wednesday 22 July 2015 07:17 PM, Krzysztof Harpula wrote:
>>> Hello,
>>>
>>> I have the following problem:
>>>
>>> I want to launch my main class using Ivy launcher as documented in Ivy
>>> manuals:
>>>
>>> java -jar ivy.jar -main com.my.MainClass
>>>
>>>
>>> My main class  expects parameters from command line in the format:
>>> -paramName:paramValue
>>>
>>> I try using Ivy launcher with -args option which is documented as
>>> follows:
>>>
>>> -args <args> the arguments to give to the launched process
>>>
>>>
>>> java -jar ivy.jar -main com.my.MainClass -args -param1:val1
>>>
>>>
>>> However Ivy is not able to pass such a parameter into my class as it
>>> interprets it as Ivy parameter which is not recognized printing:
>>> Unrecognized option: -param1:val1. (message from Ivy launcher)
>>>
>>> So if I try what follows (remove "-" from my parameter):
>>>
>>> java -jar ivy.jar -main com.my.MainClass -args param1:val1
>>>
>>>
>>> Ivy passes param1:val1 as argument to my main however my application
>>> does not recognize it as it expects its all parameters to start with "-"
>>> just as Ivy launcher does.
>>>
>>> I think this is either a *BUG* or I am missing something. It seems Ivy
>>> launcher interprets  values after -args beginning with "-" as another
>>> Ivy parameters. Is any way to pass parameters starting with "-" to the
>>> launched class? Please help.
>>>
>>> Best regards.
>>>
>>>
>>>


Re: Using Ivy launcher, passing arguments to launched class.

Posted by Krzysztof Harpula <kr...@superfund.com>.
Yes I tried in double and single quotes.  The effect is that theses
quotes are passed as part of command line arguments to  launched class
so without modification of launched class to strip off theses quotes it
still does not work. I think it is a common case that applications have
parameters starting with "-" and not expecting quotes in values of
command line arguments. It looks to be a bug in Ivy. So far I have no
work around to it.

Regards.



On 2015-07-23 14:14, Jaikiran Pai wrote:
> Have you tried to enclose those parameters in double quotes:
>
> java -jar ivy.jar -main com.my.MainClass -args "-param1:val1
> -param2:val2"
>
> -Jaikiran
>
>
>
> On Wednesday 22 July 2015 07:17 PM, Krzysztof Harpula wrote:
>> Hello,
>>
>> I have the following problem:
>>
>> I want to launch my main class using Ivy launcher as documented in Ivy
>> manuals:
>>
>> java -jar ivy.jar -main com.my.MainClass
>>
>>
>> My main class  expects parameters from command line in the format:
>> -paramName:paramValue
>>
>> I try using Ivy launcher with -args option which is documented as
>> follows:
>>
>> -args <args> the arguments to give to the launched process
>>
>>
>> java -jar ivy.jar -main com.my.MainClass -args -param1:val1
>>
>>
>> However Ivy is not able to pass such a parameter into my class as it
>> interprets it as Ivy parameter which is not recognized printing:
>> Unrecognized option: -param1:val1. (message from Ivy launcher)
>>
>> So if I try what follows (remove "-" from my parameter):
>>
>> java -jar ivy.jar -main com.my.MainClass -args param1:val1
>>
>>
>> Ivy passes param1:val1 as argument to my main however my application
>> does not recognize it as it expects its all parameters to start with "-"
>> just as Ivy launcher does.
>>
>> I think this is either a *BUG* or I am missing something. It seems Ivy
>> launcher interprets  values after -args beginning with "-" as another
>> Ivy parameters. Is any way to pass parameters starting with "-" to the
>> launched class? Please help.
>>
>> Best regards.
>>
>>
>>
>


Re: Using Ivy launcher, passing arguments to launched class.

Posted by Jaikiran Pai <ja...@gmail.com>.
Have you tried to enclose those parameters in double quotes:

java -jar ivy.jar -main com.my.MainClass -args "-param1:val1 -param2:val2"

-Jaikiran



On Wednesday 22 July 2015 07:17 PM, Krzysztof Harpula wrote:
> Hello,
>
> I have the following problem:
>
> I want to launch my main class using Ivy launcher as documented in Ivy
> manuals:
>
> java -jar ivy.jar -main com.my.MainClass
>
>
> My main class  expects parameters from command line in the format:
> -paramName:paramValue
>
> I try using Ivy launcher with -args option which is documented as follows:
>
> -args <args> the arguments to give to the launched process
>
>
> java -jar ivy.jar -main com.my.MainClass -args -param1:val1
>
>
> However Ivy is not able to pass such a parameter into my class as it
> interprets it as Ivy parameter which is not recognized printing:
> Unrecognized option: -param1:val1. (message from Ivy launcher)
>
> So if I try what follows (remove "-" from my parameter):
>
> java -jar ivy.jar -main com.my.MainClass -args param1:val1
>
>
> Ivy passes param1:val1 as argument to my main however my application
> does not recognize it as it expects its all parameters to start with "-"
> just as Ivy launcher does.
>
> I think this is either a *BUG* or I am missing something. It seems Ivy
> launcher interprets  values after -args beginning with "-" as another
> Ivy parameters. Is any way to pass parameters starting with "-" to the
> launched class? Please help.
>
> Best regards.
>
>
>