private static void startServing() throws IOException, ClassNotFoundException { // Create the handler and its associated indexer. Indexer indexer = Indexer.Factory.getIndexerByOption(SearchEngine.OPTIONS); Check(indexer != null, "Indexer " + SearchEngine.OPTIONS._indexerType + " not found!"); indexer.loadIndex(); QueryHandler handler = new QueryHandler(SearchEngine.OPTIONS, indexer); // Establish the serving environment InetSocketAddress addr = new InetSocketAddress(SearchEngine.PORT); HttpServer server = HttpServer.create(addr, -1); server.createContext("/", handler); server.setExecutor(Executors.newCachedThreadPool()); server.start(); System.out.println("Listening on port: " + Integer.toString(SearchEngine.PORT)); }