I used GnuParser()
instead of DefaultParser()
and it works well.
CommandLineParser parser = new GnuParser();
Update : In version 1.3.1 of CLI, GnuParser()
is now deprecated. So I simply added
import org.apache.commons.cli.DefaultParser;
and now I use CommandLineParser parser = new DefaultParser();
And all is fine!