Want to learn to build a simple java rest server

I just went trough this myself creating a Java server with Android client. And this two links provided plenty of info! a tip is to search for Java Socket server.

to learn JavaSocket I use http://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html And to pull it all togheter with Android client and ServerSide.

http://myandroidsolutions.blogspot.se/2012/07/android-tcp-connection-tutorial.html

Don't forgett to open ports in ur firewall to get the communication to work! to add Internet support in ur Android Manifest!


If you intend to build a simple server with sockets, you could try:

  • this SO thread for starters.
  • this interesting tutorial about sockets, and
  • the official Oracle page about sockets.

Edit this doesn't cover the "restful" side of your question though.


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: