if (config.homeDir == null) { config.homeDir = new File(sysProps.getProperty("hophome")); }  if (config.homeDir == null) { config.homeDir = new File(config.propFile.getParent()); }   try { config.homeDir = config.homeDir.getCanonicalFile(); } catch (IOException iox) { config.homeDir = config.homeDir.getAbsoluteFile(); }
    public static Config parseArgs(String[] args) throws Exception {        Config config = new Config();        if (System.getProperty("helma.home")!=null) {            config.homeDir = new File(System.getProperty("helma.home"));        }        // parse arguments        for (int i = 0; i < args.length; i++) {            if (args[i].equals("-h") && ((i + 1) < args.length)) {                config.homeDir = new File(args[++i]);            } else if (args[i].equals("-f") && ((i + 1) < args.length)) {                config.propFile = new File(args[++i]);            } else if (args[i].equals("-p") && ((i + 1) < args.length)) {                try {                    config.rmiPort = new InetAddrPort(args[++i]);                } catch (Exception portx) {                    throw new Exception("Error parsing RMI server port property: " + portx);                }            } else if (args[i].equals("-x") && ((i + 1) < args.length)) {                try {                    config.xmlrpcPort = new InetAddrPort(args[++i]);                } catch (Exception portx) {                    throw new Exception("Error parsing XML-RPC server port property: " + portx);                }            } else if (args[i].equals("-w") && ((i + 1) < args.length)) {                try {                    config.websrvPort = new InetAddrPort(args[++i]);                } catch (Exception portx) {                    throw new Exception("Error parsing web server port property: " + portx);                }            } else if (args[i].equals("-jk") && ((i + 1) < args.length)) {                try {                    config.ajp13Port = new InetAddrPort(args[++i]);                } catch (Exception portx) {                    throw new Exception("Error parsing AJP1.3 server port property: " + portx);                }            } else if (args[i].equals("-i") && ((i + 1) < args.length)) {                // eat away the -i parameter which is meant for helma.main.launcher.Main                i++;            } else {                throw new Exception("Unknown command line token: " + args[i]);            }        }        // get main property file from home dir or vice versa, depending on what we have.        // get property file from hopHome        if (config.propFile == null) {            if (config.homeDir != null) {                config.propFile = new File(config.homeDir, "server.properties");            } else {                config.propFile = new File("server.properties");            }        }        // create system properties        SystemProperties sysProps = new SystemProperties(config.propFile.getAbsolutePath());        // check if there's a property setting for those ports not specified via command line        if ((config.websrvPort == null) && (sysProps.getProperty("webPort") != null)) {            try {                config.websrvPort = new InetAddrPort(sysProps.getProperty("webPort"));            } catch (Exception portx) {                throw new Exception("Error parsing web server port property from server.properties: " + portx);            }        }        if ((config.ajp13Port == null) && (sysProps.getProperty("ajp13Port") != null)) {            try {                config.ajp13Port = new InetAddrPort(sysProps.getProperty("ajp13Port"));            } catch (Exception portx) {                throw new Exception("Error parsing AJP1.3 server port property from server.properties: " + portx);            }        }        if ((config.rmiPort == null) && (sysProps.getProperty("rmiPort") != null)) {            try {                config.rmiPort = new InetAddrPort(sysProps.getProperty("rmiPort"));            } catch (Exception portx) {                throw new Exception("Error parsing RMI server port property from server.properties: " + portx);            }        }        if ((config.xmlrpcPort == null) && (sysProps.getProperty("xmlrpcPort") != null)) {            try {                config.xmlrpcPort = new InetAddrPort(sysProps.getProperty("xmlrpcPort"));            } catch (Exception portx) {                throw new Exception("Error parsing XML-RPC server port property from server.properties: " + portx);            }        }        // get hopHome from property file        if (config.homeDir == null) {            config.homeDir = new File(sysProps.getProperty("hophome"));        }        if (config.homeDir == null) {            config.homeDir = new File(config.propFile.getParent());        }        // try to transform hopHome directory to its canonical representation        try {            config.homeDir = config.homeDir.getCanonicalFile();        } catch (IOException iox) {            config.homeDir = config.homeDir.getAbsoluteFile();        }        return config;    }