Updating Jersey/REST libraries in NetBeans 6.1
Jersey is the reference implementation of JSR 311, the specification for creating RESTful web services on the Java platform. NetBeans 6.1, the existing, current version of NetBeans, contains a copy of the Jersey library, but it may be outdated now. Recently, the Jersey implementation reached version 1.0, and NetBeans 6.1 contains a copy of an earlier 0.8 release.
If you’re already using the NetBeans 6.5 release candidate, you also have the Jersey 1.0 library. The truth is, however, that we can’t all adopt pre-release, beta software. If you fall into the latter group and need to continue using NetBeans 6.1, you may want to update your Jersey library to get the final, 1.0 version. In this blog entry, I’ll show you how to update your Jersey libraries in NetBeans 6.1.
Download the latest, stable release of the Jersey implementation. I don’t particularly like the way that the library is provided. The download page requires that you analyze your needs first, and you must select the set of jar files you need. This is difficult for the beginning Jersey user. I suggest an all-in-one download — perhaps a zip file — that provides EVERYTHING a beginning Jersey user might need. I’ll lead you through this for now, but you must understand that your real needs may actually differ from what I suggest as a basic set of starter files. Again, you need to read the download page to understand the full set of libraries and their dependencies.
In my opinion, a beginning user needs the following files to create a Jersey enabled, REST service:
Put this files together in a library directory. Put them anywhere. For this example, I’ve put them in
c:\bin\jersey. From now on, I’ll refer to your directory of Jersey files as
Create the Jersey_1.0 library in NetBeans. Open NetBeans 6.1 and select Tools->Libraries. You should see a dialog like this:
Select the New Library… option at the bottom of the dialog. You’ll see a prompt for the new libary’s name. Let’s call it Jersey_1.0
Add Jersey jar files to the Jersey_1.0 library. Do this by selecting the Add JAR/folder… button in the Library Manager for the new libary you’ve just created. Navigate to your JERSEY_HOME directory and add each jar file to the library.
Add the Jersey library to your project. Now you have the updated Jersey 1.0 jar files. They are available to your applications when you add your new library to your application project. Right-click on your project in the project view, select Properties. Then select the Libraries option in the Project Properties dialog. Now you can select the Add Library… option on the right side.
Find your Jersey_1.0 library in the available libraries list. Now you’ve got it! You have the updated Jersey 1.0 libraries in your Netbeans application project.