My problem is when I create Options
instance, and set there data, it can't read a value from my static field "ITEM_COUNT"
. Can't understand what problem is this?
public class Main {
public static final String ITEM_COUNT = "100";
public static void main( String [] args ) throws ParseException, FileNotFoundException {
Options options = new Options();
options.addOption(ITEM_COUNT, true, "The number of items being simulated" );
CommandLineParser parser = new DefaultParser();
CommandLine cmd = parser.parse( options, args );
// there I have NumberFormatException:null, the value from ITEM_COUNT is null
Integer item_count = Integer.valueOf(cmd.getOptionValue(ITEM_COUNT));
Runner mockServer = new Runner();
mockServer.initialize(item_count);
mockServer.start();
}
}
You can run Run -> Edit Configuration -> Program arguments -> -name_of_arg value_of_arg.