Skip to content
Advertisement

Java commons cli parser not recognizing command line arguments

This should be very simple but I am not sure why its not working. I am trying pass arguments with a name (So I can pass arguments in any order) using the apache commons CLI library but It seems to be not working. I want to pass the arguments from eclipse IDE. I know this part is not the problem because I am able to print the arguments with args[0] kind.

JavaScript

The above lines are exactly like the examples given online but i dont know why its not working. I am struggling this from a day now. Please help where I am going wrong.

Advertisement

Answer

According to the examples name of the parameter should be present in command line

Property without value

JavaScript

And the respective code is:

JavaScript

In this scenario correct call is:

ls -a or ls --all

With value separated by space

JavaScript

Respective code is:

JavaScript

And call would be:

JavaScript

With value separated by equals

JavaScript

The code is:

JavaScript

And call would be:

JavaScript
Advertisement