X

Geertjan's Blog

  • March 16, 2008

Lookup API Outside the NetBeans Platform

Geertjan Wielenga
Product Manager
Today an e-mail came in to the dev@openide.netbeans.org mailing list (the place you want to be if you're interested in the NetBeans Platform or in NetBeans plugin development generally) from Mark Nuttall. He asks: "Where do I snag the current Lookup API from if I want to use it outside of the NetBeans Platform." The short answer to that question is: go to the IDE's installation directory and then to the platform8/lib folder, where you will find the org-openide-util.jar. Just attach that JAR to your application's classpath and you're good to go.

The longer answer is... even better! There is an excellent article by John O'Conner, Creating Extensible Applications With the Java Platform. Not only does he describe the benefits of the Lookup API, and how to use it outside of the NetBeans Platform, but he also contrasts it to the Java SE 6 java.util.ServiceLoader class. (And, if you read Rich Client Programming: Plugging into the NetBeans Platform, you'll find out lots about these contrasts too, in chapter 4 and 5.)

However, I can't recommend John's article highly enough. He shows you how to build a pluggable application (outside of the NetBeans Platform) using both the Java SE 6 approach and the NetBeans Platform approach (and discusses the differences between the two). The article includes the complete sample code, everything, and, in fact, you end up with two different implementations of a Dictionary application. Below you see the result, i.e., everything in the screenshot below comes straight from the downloadable sources from John's article. So you end up with three applications, the first providing the user interface, and the other two are registered services (I have also highlighted the Lookup API JAR below so that you can see its name):

Anyone new to, or confused about, Lookup is advised to read the above article, download the sources, play with them, see how they relate to each other, read the article again, and then try and make something similar yourself to see if you really understand it. The NetBeans Lookup API isn't discussed to its full extent and so reading chapter 4 and 5 of "Rich Client Programming: Plugging into the NetBeans Platform" is a very worthwhile thing to do after you've understood everything that John's article provides. It is basically an excellent primer on loosely coupled communication between a system's components.

In other news. Check out the NetBeans blogging contest!

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.