private static UserParameters parseCommandLine(String args[]) throws ParseException {        
        Options options = createOptions();        
        CommandLineParser parser = new PosixParser(); 
        CommandLine line = parser.parse(options, args);
                
        String scene = null;
        int xResolution = 512;
        int yResolution = 512;
        String output = null;
        
        if (args.length == 0 || line.hasOption("h")) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("java -jar scenerenderer.jar", options);
            return null;            
        } else {
            if (!line.hasOption("scene")) {
                throw new ParseException("Parameter 'scene' is mandatory");
            } else {
                scene = line.getOptionValue("scene");
            }

            if (!line.hasOption("output")) {
                throw new ParseException("Parameter 'output' is mandatory");
            } else {
                output = line.getOptionValue("output");
            }

            try {
                if (line.hasOption("resolution_x")) {
                    xResolution = Integer.parseInt(line.getOptionValue("resolution_x"));
                }

                if (line.hasOption("resolution_y")) {
                    yResolution = Integer.parseInt(line.getOptionValue("resolution_y"));
                }
            } catch (NumberFormatException ex) {
                throw new ParseException(ex.getMessage());
            }
        }
        
        if (!output.endsWith(".png")) {
            output = output + ".png";
        }
        
        return new UserParameters(scene, xResolution, yResolution, output);
    }