public static void main()

in modules/jdktools/src/main/java/org/apache/harmony/tools/appletviewer/Main.java [43:148]


    public static void main(String argv[]) throws Exception {

        if (argv.length == 0) {
            printHelp();
            return;
        }

        ArrayList<String> propertiesList = new ArrayList<String>();
        ArrayList<String> urlsList = new ArrayList<String>();

        for(int i = 0; i < argv.length; i++){
            if(argv[i].startsWith("-D")){
                propertiesList.add(argv[i].substring(2));
            } else {
                urlsList.add(argv[i]);
            }
        }

        if (urlsList.size() == 0) {
            printHelp();
            return;
        }

        // Load stored java.properties
        String userHomeDir = System.getProperty("user.home");
        propertiesFile = new File(userHomeDir + 
            File.separator + Main.propertiesFileName);

        boolean needStore = false;
        if(propertiesFile.exists()){
            try{
                properties.load(new FileInputStream(propertiesFile));
            } catch(IOException e){
            }
        } else {
            properties.setProperty(httpProxyHost, "");
            properties.setProperty(httpProxyPort, "");
            properties.setProperty(httpsProxyHost, "");
            properties.setProperty(httpsProxyPort, "");
            properties.setProperty(ftpProxyHost, "");
            properties.setProperty(ftpProxyPort, "");
            needStore = true;
        }
        

        // Parse command line java.properties

        Iterator<String> iterator = propertiesList.iterator();
        while(iterator.hasNext()){
            String prop = iterator.next();
            if(prop != null){
                String[] pair = prop.split("=");
                String key = null;
                String val = null;

                if(pair[0] != null){
                    key = pair[0].trim();
                }

                if(pair[1] != null){
                    val = pair[1].trim();
                }

                if(key != null && key != "" && val != null && val != ""){
                    if(validatePropertyName(key)){
                        properties.setProperty(key, val);
                        needStore = true;
                    } else {
                        System.err.println("Unknown proxy property: " + key);
                        System.exit(-1);
                    }

                    if(key.endsWith("Port")){
                        try{
                            if(Integer.parseInt(val) < 0){
                                wrongPortMessage(val);
                                System.exit(-1);
                            }
                        } catch(NumberFormatException ex){
                            wrongPortMessage(key);
                            System.exit(-1);
                        }
                    }
                }
            }
        }

        if(needStore) storeProxyProperties();

        Enumeration<?> e = properties.propertyNames();

        while(e.hasMoreElements()){
            String key = (String)e.nextElement();
            String val = properties.getProperty(key);
            if(val != null && val != ""){
                System.setProperty(key, val);
            }
        }

        HTMLParser parser = new HTMLParser();
        Object []applets = parser.parse(urlsList.toArray(new String[urlsList.size()]), 0);
        
        // Start applets
        for (int i = 0; i < applets.length; i++)
            new AppletFrame((AppletInfo)applets[i]);
    }