Developing JAX-RS resources

JAX-RS resources are developed by using annotations defined within the JAX-RS specification. This enables fast development time and eliminates the need for excessive deployment descriptor information. The following steps will outline the process for developing a simple JAX-RS Address Book resource.

Configuring a Development Environment

To start developing JAX-RS applications, you first need to configure a development environment that will allow you to compile your resources with the JAX-RS API classes.

Using Eclipse

The Eclipse Project provides a very useful tool for developing Java applications. You can use the Eclipse tools to develop JAX-RS resources using the instructions below.

  1. Create a new Java project

    Start by creating a new space for the JAX-RS application. From the menu bar at the top, go to File > New > Project... Select "Java Project" and click "Next". On the next panel, type in your desired project name and click "Finish".


  2. Configure the classpath

    To compile JAX-RS applications, you will need the appropriate JARs in your classpath containing the JAX-RS annotation and interface classes. You can import these into your new Java project by selecting your project in the Package Explorer panel and right clicking. Click on the "properties" option which should be toward the bottom of the list.

    From the properties panel, click on "Java Build Path" on the left. This should bring up a set of tabs on the right-hand side. Select the "Libraries" tab at the top. Click on the "Add External Jars..." button and browse to the directory that contains your IBM JAX-RS distribution. Find the ibmjaxrs-{version}-api.jar, select it and click "Ok".

    At this point, the ibmjaxrs jar should show up in your project. You're now ready to begin developing JAX-RS resources using this configuration.




Using the command line environment