title: How to handle empty parameters in a main method java call
body: <p>I would like to have a dynamic way of passing in parameters to a java main method call which is done via the Command Line(cmd) to a Runnable JAR file. At the moment my main() method takes 6 parameters and sets each one to a variable before calling another method with those variables passed in.</p>
  
  <p>What id like is a way to give a user the ability to pass 5 or less paramters to the command line and have it safely handle the missed parameter by setting it to null or an empty string("") value.</p>
  
  <p>For example, if I ran the command below, it should know to set the missing parameters I have not specified(clientName and outputFolder), to an empty String.</p>
  
  <pre><code>java -Xmx1024m -jar MainApp.jar "Summary" **&lt;missing&gt;** "2015-06-07" "https://12345.bp.com/bp/" "c:\\Parameters.txt" **&lt;missing&gt;**
  </code></pre>
  
  <p>Here is the code I have for my main method:</p>
  
  <pre><code>public static void main(String[] args) {
          try {               
              String dType = args[0];
              String clientName = args[1];
              String cycleString = args[2];
              String mspsURL = args[3];
              String inputFile = args[4];
              String outputFolder = args[5];
  
              System.out.println("**Main Parameters passed**");
              for(String x : args) {
                  System.out.println(x);
              }
  
              runLogic(dType, clientName, cycleString, 
                      mspsURL, inputFile, outputFolder);          
          } catch(Exception ex) {
              ex.printStackTrace();
          }
      }
  </code></pre>
  
  <p>Any help appreciated.</p>