Created
November 4, 2013 12:13
-
-
Save rjdkolb/7301662 to your computer and use it in GitHub Desktop.
How to spin up a restful webserver with jersey 1.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import com.sun.jersey.api.container.httpserver.HttpServerFactory; | |
import com.sun.jersey.api.core.PackagesResourceConfig; | |
import com.sun.jersey.api.core.ResourceConfig; | |
import com.sun.net.httpserver.HttpServer; | |
public class RunRest { | |
static final String BASE_URI = "http://localhost:9999/rest/"; | |
public static void main(String[] args) { | |
try { | |
ResourceConfig rc = new PackagesResourceConfig("org.openrap.rest"); | |
HttpServer server = HttpServerFactory.create(BASE_URI, rc); | |
server.start(); | |
System.out.println("Press Enter to stop the server. "); | |
System.in.read(); | |
server.stop(0); | |
} catch (IllegalArgumentException e) { | |
e.printStackTrace(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment