Want to learn to build a simple java rest server [closed]

六眼飞鱼酱① 提交于 2019-12-31 08:47:07

问题


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?


回答1:


At first you should read and learn how to use Jersey.This is the best implementation of JAX-RS API (REST for Java) https://jersey.java.net/ Then you will need a good HTTP server and Java Servlet container.I advice you to use Jetty http://www.eclipse.org/jetty/ Here good tutorials:

  1. http://crunchify.com/how-to-build-restful-service-with-java-using-jax-rs-and-jersey/ http://www.vogella.com/tutorials/REST/article.html

You said "simple server" but if you want high performance then read this tutorial http://www.javarants.com/2008/12/27/using-jax-rs-with-protocol-buffers-for-high-performance-rest-apis/ and use Grizzly container instead of Jetty: https://grizzly.java.net/




回答2:


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.




回答3:


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!



来源:https://stackoverflow.com/questions/17381194/want-to-learn-to-build-a-simple-java-rest-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!