Extract common code for Main classes from examples.

This changes how the mains are run. Previously one could run
  - `java -jar server.jar -init`
  - `java -jar server.jar -serve`
  - `java -jar server.jar -init -serve`

Now one can run:
  - `java -jar server.jar init`
  - `java -jar server.jar serve`

Previously the `-init` and `-serve` were flags that could appear anywhere in the other flags. Now `init` and `serve` are commands that must appear first. Previously, one could init and serve in one run. Now they must be separate runs.