For Jersey 2.x you will need jersey-container-jdk-http in your class path. If you are using maven, add this to your pom.xml :
<dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-jdk-http</artifactId> <version>2.9.1</version> </dependency>
To start the server, use this:
URI baseUri = UriBuilder.fromUri("http://localhost/").port(10000).build(); ResourceConfig resourceConfig=new ResourceConfig(WebService.class); HttpServer httpServer=JdkHttpServerFactory.createHttpServer(baseUri, resourceConfig,true);
Thunder
source share