Below is the code to start Grizzly Http Server. If I press any key the server stops. Is there any way to keep it alive.
Jetty has join() method, which will not exit the main program. Is there anything similar to that in Grizzly also.
public static void main(String args){
ResourceConfig rc = new PackagesResourceConfig("com.test.resources");
HttpServer httpServer = GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
logger.info(String.format("Jersey app started with WADL available at "
+ "%sapplication.wadl\nTry out %shelloworld\nHit enter to stop it...",
BASE_URI, BASE_URI));
System.in.read();
httpServer.stop();
}
As per the above code, if you hit any key the server stops. I want to keep it running. I will kill the process when I actually want to stop the server. The main method should not terminate.
Thanks