webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Quoridor.java
changeset 121 95dfb04fcee1
parent 85 3574b08dc3c3
child 123 4529cb22ff7d
     1.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Quoridor.java	Mon Sep 14 16:11:39 2009 +0200
     1.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Quoridor.java	Sun Oct 11 14:20:19 2009 +0200
     1.3 @@ -121,9 +121,15 @@
     1.4      //
     1.5  
     1.6      public static void main(String[] args) throws IOException {
     1.7 -        HttpServer s = start(9998);
     1.8 +        int port = 9222;
     1.9 +        try {
    1.10 +            port = Integer.parseInt(args[0]);
    1.11 +        } catch (Exception ex) {
    1.12 +            // OK
    1.13 +        }
    1.14 +        HttpServer s = start(port);
    1.15          System.out.println(
    1.16 -            "Quoridor started at port 9998\n" + "Hit enter to stop it..."
    1.17 +            "Quoridor started at port " + port + "\n" + "Hit enter to stop it..."
    1.18          );
    1.19          System.in.read();
    1.20          s.stop(0);
    1.21 @@ -138,10 +144,11 @@
    1.22          }
    1.23          final String baseUri = "http://localhost:" + port + "/";
    1.24  
    1.25 -        File home = new File(System.getProperty("user.home"));
    1.26 -        File quoridor = new File(home, ".quoridor");
    1.27 -
    1.28 -        System.setProperty("quoridor.dir", quoridor.getPath());
    1.29 +        if (System.getProperty("quoridor.dir") == null) {
    1.30 +            File home = new File(System.getProperty("user.home"));
    1.31 +            File quoridor = new File(home, ".quoridor");
    1.32 +            System.setProperty("quoridor.dir", quoridor.getPath());
    1.33 +        }
    1.34  
    1.35          ResourceConfig rc = new PackagesResourceConfig("cz.xelfi.quoridor.webidor");
    1.36          HttpServer server = HttpServerFactory.create(baseUri, rc);