20

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?

Yosi199
  • 1,745
  • 4
  • 22
  • 47

3 Answers3

19

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:

Oleksandr Karaberov
  • 12,573
  • 10
  • 43
  • 70
  • 1
    Very well, I will read all of this and will see how it goes and yes this server shouldn't be anything fancy - there will be only 1 - 2 concurrent client connections. – Yosi199 Jun 29 '13 at 14:42
  • @Yosi199 Then you doesn't need Grizzly and Protocol Buffers:)it will be an overhead.And if you will have a question Tomcat or Jetty - I advice you to use Jetty: https://www.webtide.com/choose/jetty.jsp – Oleksandr Karaberov Jun 29 '13 at 14:45
5

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.

Community
  • 1
  • 1
Mena
  • 47,782
  • 11
  • 87
  • 106
1

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!