I am trying to write a program which when executed java -jar -cf file.txt will retrieve the value of the cf argument. The code I have so far is:
Options options = new Options();
final Option configFileOption = Option.builder("cf")
.longOpt("configfile")
.desc("Config file for Genome Store").argName("cf")
.build();
options.addOption(configFileOption);
CommandLineParser cmdLineParser = new DefaultParser();
CommandLine commandLineGlobal= cmdLineParser.parse(options, commandLineArguments);
if(commandLineGlobal.hasOption("cf")) {
System.out.println(commandLineGlobal.getOptionValue("cf"));
}
The problem I am facing is that the value which is being printed is null. Could anyone tell me what I am missing?