#vulnerable code 
                                public static void main(String[] args) throws Exception {
        Main main = new Main();
        for (int i = 0; i < args.length; i++) {
            if ("-help".equals(args[i]) || "--help".equals(args[i])) {
                printHelp();
                System.exit(0);
            } else if ("-classpath".equals(args[i]) || "-cp".equals(args[i]) || "-lib".equals(args[i])) {
                main.setClassPaths(args[++i]);
            } else if ("-d".equals(args[i])) {
                main.setOutputDirectory(args[++i]);
            } else if ("-o".equals(args[i])) {
                main.setOutputName(args[++i]);
            } else if ("-cpp".equals(args[i]) || "-nocompile".equals(args[i])) {
                main.setCompile(false);
            } else if ("-jarprefix".equals(args[i])) {
                main.setJarPrefix(args[++i]);
            } else if ("-properties".equals(args[i])) {
                main.setProperties(args[++i]);
            } else if ("-propertyfile".equals(args[i])) {
                main.setPropertyFile(args[++i]);
            } else if (args[i].startsWith("-D")) {
                main.setProperty(args[i]);
            } else if (args[i].startsWith("-")) {
                System.err.println("Error: Invalid option \"" + args[i] + "\"");
                printHelp();
                System.exit(1);
            } else {
                main.setClassesOrPackages(args[i]);
            }
        }
        main.build();
    } 
                            #location 31 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                public static void main(String[] args) throws Exception {
        Main main = new Main();
        for (int i = 0; i < args.length; i++) {
            if ("-help".equals(args[i]) || "--help".equals(args[i])) {
                printHelp();
                System.exit(0);
            } else if ("-classpath".equals(args[i]) || "-cp".equals(args[i]) || "-lib".equals(args[i])) {
                main.classPaths(args[++i]);
            } else if ("-d".equals(args[i])) {
                main.outputDirectory(args[++i]);
            } else if ("-o".equals(args[i])) {
                main.outputName(args[++i]);
            } else if ("-cpp".equals(args[i]) || "-nocompile".equals(args[i])) {
                main.compile(false);
            } else if ("-jarprefix".equals(args[i])) {
                main.jarPrefix(args[++i]);
            } else if ("-properties".equals(args[i])) {
                main.properties(args[++i]);
            } else if ("-propertyfile".equals(args[i])) {
                main.propertyFile(args[++i]);
            } else if (args[i].startsWith("-D")) {
                main.property(args[i]);
            } else if (args[i].startsWith("-")) {
                System.err.println("Error: Invalid option \"" + args[i] + "\"");
                printHelp();
                System.exit(1);
            } else {
                main.classesOrPackages(args[i]);
            }
        }
        main.build();
    }