Make a command line application with parameter I made a command line application which uses parameters. So I try to make a system like the linux command.
So I have 4 parameters, initialized to a default value, used if wrong or none parameter are given. The user can modify those parameter by calling associate options "-options".

   public static void main(String [] args) {
    String locParameter = "centralOffice";
    String dirResult = "//home//"+System.getProperty("user.name")+"//Documents//ResultMyApp";
    int periodParameter = 24;
    String counterParameter = "ALL";
    int i = 0;

    for (String s: args) {
        switch (s) {
            case "-o":  if (args[i+1].equalsIgnoreCase("remote")){
                            locParameter = "remoteOffice";
                            break;
                        } else if (args[i+1].equalsIgnoreCase("central")){
                            locParameter = "centralOffice";
                            break;
                        } else {
                            System.err.println("Unknow parameter for location, default value: centralOffice");
                            break;
                        }
            case "-p":  dirResult = args[i+1];
                        break;
            case "-kpi": counterParameter = args[i+1].toUpperCase();
                        break;
            case "-t":  try { 
                            periodParameter = Integer.parseInt(args[i+1]) ;               
                        } catch(NumberFormatException e){
                            System.err.println("Error parsing parameter, default value 24 hours");
                        } finally {
                            break;
                        }
        }
        i++;
    }

    System.out.println("parameter choosed: " + locParameter + ", " + periodParameter + ", " + counterParameter );}


So I am wondering, is this ok? Of course it works but maybe it is not the easiest way to do it or the most optimized code.
Parameter validation is sorely missing. For example, if you call this with -o as last argument (no more arguments), the program will crash with an array index out of bounds exception and a stack trace. Getting a lengthy stack trace for invalid output is not very UNIX-y ;-)

The finally in the exception handling is not necessary and a bit confusing. I suggest simply moving the break after the catch.

The indenting is a bit strange. I suggest to use an IDE to reformat nicely.

In any case, instead of worrying your own, I suggest using a library. Recently I tried Argparse4j, and I'm happy to say I really like it, works very well for me.