Want to learn to build a simple java rest server

Yosi199 picture Yosi199 · Jun 29, 2013 · Viewed 30.2k times · Source

Hello people of the world!

I'm an Android developer and so far I've worked only on the client side. My next project is in need of a server to communicate with and I wanna try to build it myself.

Can someone give me direction to a good source of learning how to build a nice, small and simple Java restful server?

I've looked around, there is way too much info out there and it's confusing. Maybe one of you was in my shoes already and know a good source for it?

Answer

Oleksandr Karaberov picture Oleksandr Karaberov · Jun 29, 2013

First of all you should read up on and learn how to use Jersey. This is the best implementation of JAX-RS API (REST for Java).

You will also need a good HTTP server and Java Servlet container. For that I'd advise you to use Jetty. Here are a few good tutorials:

  1. Crunchify: Build RESTful Service in Java using JAX-RS and Jersey (Celsius to Fahrenheit & Fahrenheit to Celsius)
  2. Vogella: REST with Java (JAX-RS) using Jersey - Tutorial

You asked for a "simple server", however if you're looking for high performance then read this tutorial: Javarants: Using JAX-RS with Protocol Buffers for high-performance REST APIs, and use the Grizzly container instead of Jetty: