public static void main(String[] args) {
        Simulation s = new Simulation();

        // Clean up if control-C is pressed
        Runtime.getRuntime().addShutdownHook(s.new Cleanup());
        
        if (args.length != 1) {
            System.err.println("Usage error: run as <program> <specfile> for a single XML world spec.");
        }
        try {
            // Set up SAX reader, which processes XML objects as file is read.
            XMLReader xr = XMLReaderFactory.createXMLReader();      
            FlockingReader handler = new FlockingReader(s);
            xr.setContentHandler(handler);
            xr.setErrorHandler(handler);
            
            // Parse the XML
            FileReader r = new FileReader(args[0]);
            xr.parse(new InputSource(r));

            // Show the simulation on screen, if you haven't already
            s.w = handler.getWorld();
            if (s.w == null)
            	s.pack();
            s.setVisible(true);

            // Get ready to record activities
            if (s.w != null) 
                s.w.startLogging();

            // Run any simulation indefinitely
            while (s.w != null && s.w.isRunnable()) {
                s.w.stepWorld();
                try {
                    Thread.sleep(s.w.getDelay());
                }
                catch (InterruptedException e) {
                }
            }
            
            // Clean up if the world spec did not want a simulation
            s.processWindowEvent(new WindowEvent(s, WindowEvent.WINDOW_CLOSING));
            
        } catch (SAXException e) {
            System.err.println(e.getMessage());
        } catch (FileNotFoundException e) {
            System.err.println(e.getMessage());
        } catch (IOException e) {
            System.err.println(e.getMessage());
        }

    }