title: How can I pass arguments to my Java main method using run configuration arguments in Eclipse?
body: <p>I'm using apache commons cli to parse the arguments.
  The help outputs:</p>
  
  <pre><code>usage: Code Generation
  -d,--delete           
  -f,--factory &lt;arg&gt;    
  -o,--output &lt;arg&gt;     
  -p,--package &lt;arg&gt;    
  -r,--reasoner &lt;arg&gt;
  </code></pre>
  
  <p>The arguments I'm trying to pass in the run configuration argument tab are:</p>
  
  <p>-f "FactoryName" -o "~/MyFolder" -p "generatedcode"</p>
  
  <p>The execution seems to stop because parsedOptions.getArgList().size() returns 0</p>
  
  <p>The critical part of the parsing code is as follows:</p>
  
  <pre><code>public static void main(String [] args) throws Exception {
  CommandLine parsedOptions = parseArguments(args);
  String outputFolderName = parsedOptions.getOptionValue("o");
  File outputFolder = outputFolderName != null ? new File(outputFolderName) : new File("");
  if (parsedOptions.getArgList().size() != 1) { // This should be false..
  help();
  System.exit(-1);
  }
  //Some other code
  }
  </code></pre>
  
  <p>How can I fix this?</p>