Sunday 16 November 2008

Java: Using Jersey and Grizzly to create a RESTful Framework for Web Applications

Here are some notes if you want to get started building a basic Jersey / Grizzly REST framework. The information here should be enough to get you started with the application launcher and a couple of resources which you can then test in a browser.

I got started by following the notes here as much as possible and then tried to boil the information down in order to give myself the most basic understanding of how these frameworks could be used in projects:

I created a new project in my favourite editor (IntelliJ IDEA) and then placed the following .jar files in my lib directory:

In the src folder, I created the following files (note: you'll need to edit the line containing "YOUR.NAMESPACE.HERE" and replace it with your namespace:

I placed the next two files in a folder called resources (src/YOUR/NAMESPACE/resources), so the config class could find and register them:

Once they're all in place and you have imported the jar folder into the project, you should be able to run LaunchApp and visit the following URIs:

And finally, I got myself up and running by looking at this page and downloading the project:

I hope this helps someone get started quickly.

1 comment:

benjiiiiii said...

I have a quesiton about this post.
Is that important to use the path your.domain.resources
and the suffixe Resource for the resources?