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.
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.
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.
java -Xmx1024m -jar MainApp.jar "Summary" **<missing>** "2015-06-07" "https://12345.bp.com/bp/" "c:\\Parameters.txt" **<missing>**
Here is the code I have for my main method:
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();
        }
    }
Any help appreciated.
 
     
    