Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easiest frameworks to implement Java REST web services [closed]

What are the best frameworks for implementing both client and server REST frameworks in Java? I've been struggling a little to find an easy to use solution.

Update: Both Jersey and Restlet seem like good options. We'll probably use Restlet but we'll experiment with both.

like image 599
Marcus Leon Avatar asked Sep 30 '09 02:09

Marcus Leon


People also ask

Which frameworks is used to build REST web services?

REST has now become a standard way to develop web services, and When it comes to Java, there are many frameworks and libraries available, like JAX-RS, Restlet, Jersey, RESTEasy, Apache CFX, etc.. Still, I encourage Java developers to use Spring MVC to develop RESTful web services.

What is the best framework to create REST API?

Django (Python) Django Rest Framework is easy to use when building your REST APIs with Django. It has a steeper learning curve for beginners, but comes with great built-in features like authentication and messaging.

Does Java support REST API?

The code for REST APIs can be written in multiple languages but Java Programming Language due to its “write once run anywhere” quality is preferred for creating these APIs.


2 Answers

Jersey is really easy for both. To write web services, you use annotations:

@Path("/helloworld")
public class HelloWorldResource {

    // The Java method will process HTTP GET requests
    @GET
    // The Java method will produce content identified by the MIME Media
    // type "text/plain"
    @Produces("text/plain")
    public String helloWorld() {
        // Return some cliched textual content
        return "Hello World";
    }
}

For a client:

Client client = Client.create();
WebResource webResource = client.resource("http://localhost:8080/helloworld");
String s = webResource.get(String.class);
System.out.println(s); // prints Hello World
like image 106
Droo Avatar answered Oct 01 '22 02:10

Droo


Restlet sounds like it should provide what you're looking for:

  • Support for client and server (in a relatively symmetric api)
  • Smart url binding
  • mime type understanding (given accepted mime types, it will ask your resources for their representation in that type)
  • Supports JAX-RS annotations (just like Jersey)
like image 20
Stephen Avatar answered Oct 01 '22 02:10

Stephen