This repository contains one application based on RestEasy, and another based on Jersey. Those are JAX-RS (think RESTful services) implementations readily usable in a Java SE environment. For example, small apps or 12 factor apps.
Think what you will about the enterprise Java as a whole, some of their technologies are really neat. Also, since they are more and more usable without any heavy frameworks or boilerplate or configuration, they are a real contender in Java SE space.
JAX-RS allows you to build RESTful APIs in a type safe and easy way.
This project contains a jaxrs
resources archive, which is just a JAR really.
This JAR forms the actual application.
There’s an IndexResource
that is exposed in the /
path,
and it exposes two sub-resources in path /articles
and /inquiries
.
You can make GET
requests to the /articles
end point, and receive a JSON list of articles.
You can also POST
inquiries the the /inquiries
end point.
Then there are two Java applications: jersey-jdk and resteasy-jdk.
Both are really small.
All they do is, they use container specific way of constructing the JAX-RS container
and then start the JDK HttpServer
.
That’s it. (See the source code for more comments.)
I’m using gradle build system, but you do not need to install that in order to build this. All you need is Java SE JDK, version 8.
Clone this repository:
git clone https://github.com/vmj/jaxrs-se-example.git cd jaxrs-se-example
And build the app:
./gradlew installDist
Then run the Jersey based app:
./jersey-jdk/build/install/jersey-jdk/bin/jersey-jdk
And the RestEasy based app:
./resteasy-jdk/build/install/resteasy-jdk/bin/resteasy-jdk
If you’re on Windows, add .bat
suffix to each script (gradlew.bat
, jersey-jdk.bat
, resteasy-jdk.bat
).
You can clean up, too
./gradlew clean
Have fun!