Processing of empty args with required parameters AND help=true for one of the declared parameters
If you are using JCommander to parse your commander, you may encounter the situations shown below: You have an option that is required. For example: @Parameter(names = { "-i", "--input-file"}, description = "Input file [.bed]", required = true) private String input; If you run your program without args (empty args) using SortBedErr.java , you will get the error message shown below: Exception in thread "main" com.beust.jcommander.ParameterException: The following option is required: -i, --input-file at com.beust.jcommander.JCommander.validateOptions(JCommander.java:321) at com.beust.jcommander.JCommander.parse(JCommander.java:283) at com.beust.jcommander.JCommander.parse(JCommander.java:265) at com.readbio.smRNACluster.bedtools.SortBed.main(SortBed.java:22) To sovle this problem, you can catch ParameterException when the args is empty and print usage using usage() method. You can look into SortBed.java and get the detailed codes...