You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Thomas Brand <to...@trellis.ch> on 2016/08/05 11:49:54 UTC

Commons CLI - possible faulty build

Hi,

i was looking for a tool to parse command line arguments in Java and came
to Apache Commons CLI.

I noticed that using the binary package (commons-cli-1.3.1.jar) from
http://www.pirbot.com/mirrors/apache//commons/cli/binaries/commons-cli-1.3.1-bin.tar.gz
doesn't work. The program compiles but prints the following error:

Exception in thread "main" java.lang.NoSuchMethodError:
org.apache.commons.cli.Options.hasShortOption(Ljava/lang/String;)Z
	at
org.apache.commons.cli.DefaultParser.handleShortAndLongOption(DefaultParser.java:490)

The jar is in the classpath, it's NOT a classpath issue.
Building from source using, all works as expected.
You might want to review the binary release.

A minor issue i found with the method Option.getArgs().
It's said that
"Returns the number of argument values this Option can take."
However, if an option doesn't take any value, the return of this method is
-1 which seems wrong. Does this sound right?


Thanks and best regards
Thomas



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Commons CLI - possible faulty build

Posted by Thomas Brand <to...@trellis.ch>.
Hi Benedikt,

thanks for taking a look at it!

On Thu, August 18, 2016 12:19, Benedikt Ritter wrote:

>>> I noticed that using the binary package (commons-cli-1.3.1.jar) from
>>>
>>>
>>> http://www.pirbot.com/mirrors/apache//commons/cli/binaries/commons-cl
>>> i-1.3.1-bin.tar.gz doesn't work. The program compiles but prints the
>>> following error:
>>>
>>> Exception in thread "main" java.lang.NoSuchMethodError:
>>> org.apache.commons.cli.Options.hasShortOption(Ljava/lang/String;)Z at
>>>
>>> org.apache.commons.cli.DefaultParser.handleShortAndLongOption(Default
>>> Parser.java:490)
>>>
>>>
>>> The jar is in the classpath, it's NOT a classpath issue.
>>> Building from source using, all works as expected.
>>> You might want to review the binary release.
>>>
>>>
>>
>> Although you're sure that your classpath is correct, the error message
>> indicates a problem with the classpath. I've setup a minimal sample
>> project calling the hasShortOption(String) method and it works [1]. Are
>> your sure you're really pulling in the right version of Commons CLI? If
>> so, can you provide a sample project for us to investigate?
>>

I can't reproduce now using the jar form the above link and a test program
(!). This is really strange since i was almost 100% it wasn't a classpath
issue but reality proves me wrong. Next time i should save the artifacts
for better reproduction. I apologize for the false alarm.

>>
>>>
>>> A minor issue i found with the method Option.getArgs().
>>> It's said that
>>> "Returns the number of argument values this Option can take."
>>> However, if an option doesn't take any value, the return of this
>>> method is -1 which seems wrong. Does this sound right?
>
> A value of -1 indicates the number of arguments has not been specified.
> There is a constant in Option for this (UNINITIALIZED). I've added this
> information to the JavaDoc in revision 1756753 [1].
>

This is an important bit of information (especially for the ones not
looking inside the code), thanks for pointing it out.

Best regards
Thomas



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Commons CLI - possible faulty build

Posted by Benedikt Ritter <br...@apache.org>.
Hello Thomas,

Benedikt Ritter <br...@apache.org> schrieb am Do., 18. Aug. 2016 um
12:09 Uhr:

> Hello Thomas,
>
> Thomas Brand <to...@trellis.ch> schrieb am Fr., 5. Aug. 2016 um 13:50 Uhr:
>
>> Hi,
>>
>> i was looking for a tool to parse command line arguments in Java and came
>> to Apache Commons CLI.
>>
>> I noticed that using the binary package (commons-cli-1.3.1.jar) from
>>
>> http://www.pirbot.com/mirrors/apache//commons/cli/binaries/commons-cli-1.3.1-bin.tar.gz
>> doesn't work. The program compiles but prints the following error:
>>
>> Exception in thread "main" java.lang.NoSuchMethodError:
>> org.apache.commons.cli.Options.hasShortOption(Ljava/lang/String;)Z
>>         at
>>
>> org.apache.commons.cli.DefaultParser.handleShortAndLongOption(DefaultParser.java:490)
>>
>> The jar is in the classpath, it's NOT a classpath issue.
>> Building from source using, all works as expected.
>> You might want to review the binary release.
>>
>
> Although you're sure that your classpath is correct, the error message
> indicates a problem with the classpath. I've setup a minimal sample project
> calling the hasShortOption(String) method and it works [1]. Are your sure
> you're really pulling in the right version of Commons CLI? If so, can you
> provide a sample project for us to investigate?
>
>
>>
>> A minor issue i found with the method Option.getArgs().
>> It's said that
>> "Returns the number of argument values this Option can take."
>> However, if an option doesn't take any value, the return of this method is
>> -1 which seems wrong. Does this sound right?
>>
>>
> Thank you for the pointer, I'll have a look at this.
>

A value of -1 indicates the number of arguments has not been specified.
There is a constant in Option for this (UNINITIALIZED). I've added this
information to the JavaDoc in revision 1756753 [1].

Thank you,
Benedikt

[1] http://svn.apache.org/viewvc?view=revision&revision=1756753


>
> Regards,
> Benedikt
>
> [1] https://github.com/britter/clitest
>
>
>>
>> Thanks and best regards
>> Thomas
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>

Re: Commons CLI - possible faulty build

Posted by Benedikt Ritter <br...@apache.org>.
Hello Thomas,

Thomas Brand <to...@trellis.ch> schrieb am Fr., 5. Aug. 2016 um 13:50 Uhr:

> Hi,
>
> i was looking for a tool to parse command line arguments in Java and came
> to Apache Commons CLI.
>
> I noticed that using the binary package (commons-cli-1.3.1.jar) from
>
> http://www.pirbot.com/mirrors/apache//commons/cli/binaries/commons-cli-1.3.1-bin.tar.gz
> doesn't work. The program compiles but prints the following error:
>
> Exception in thread "main" java.lang.NoSuchMethodError:
> org.apache.commons.cli.Options.hasShortOption(Ljava/lang/String;)Z
>         at
>
> org.apache.commons.cli.DefaultParser.handleShortAndLongOption(DefaultParser.java:490)
>
> The jar is in the classpath, it's NOT a classpath issue.
> Building from source using, all works as expected.
> You might want to review the binary release.
>

Although you're sure that your classpath is correct, the error message
indicates a problem with the classpath. I've setup a minimal sample project
calling the hasShortOption(String) method and it works [1]. Are your sure
you're really pulling in the right version of Commons CLI? If so, can you
provide a sample project for us to investigate?


>
> A minor issue i found with the method Option.getArgs().
> It's said that
> "Returns the number of argument values this Option can take."
> However, if an option doesn't take any value, the return of this method is
> -1 which seems wrong. Does this sound right?
>
>
Thank you for the pointer, I'll have a look at this.

Regards,
Benedikt

[1] https://github.com/britter/clitest


>
> Thanks and best regards
> Thomas
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>