Installing and running the plug-in

Let's put everything together so that we can run our new plug-in. 

First, we need to compile our classes into a jar called helloworld.jar. Why? Because that's where we told the platform our plug-in could be found. You can do this by selecting the project, choosing File > Export and exporting your generated class file to a JAR File

Next, we install the plug-in into a directory underneath the platform's plug-in directory. This directory corresponds to our plug-in id, which must be unique.  The standard practice for plug-in directory names is to use the plug-in's fully qualified id, including the dots.  In this case, we need to create a directory named org.eclipse.examples.helloworld inside the platform's plug-in directory. (The plug-in directory is named plugins and is typically located underneath the main directory where you installed the platform.) We copy the helloworld.jar and the plugin.xml to this new directory.  (You can export the plugin.xml to the file system using the File > Export wizard with destination type File system.)

If you are currently running the workbench, you will need to shut it down and restart it.  When the platform starts, it assembles a list of all of the plug-ins installed in the system, called the plug-in registry. This registry keeps track of plug-ins and the extension points that they contribute.  Restarting the workbench will cause it to find your new plug-in.

(Note:  We are installing our plug-in and launching the workbench ourselves to show exactly how plug-ins are installed and found in the platform.  The PDE plug-in automates much of this process by introducing a special launcher that launches a self-hosted workbench.  We are ignoring this for now to keep things simple.) 

How do we run the plug-in?  We can see all of the views that have been contributed by plug-ins using the Window >Show View menu.

This menu shows us what views are available for the current perspective. You can see all of the views that are contributed to the platform (regardless of perspective) by selecting Other.... This will display a list of view categories and the views available under each category.

The workbench creates the full list of views by using the plug-in registry to find all the plug-ins that have provided extensions for the org.eclipse.ui.views extension point.

Show View dialog with Hello entry

There we are! The view called "Hello Greetings" has been added to the Show View window underneath our category "Hello." The labels for our category and view were obtained from the extension point configuration markup in the plugin.xml.

Up to this point, we still have not run our plug-in code!  The declarations in the plugin.xml (which can be accessed via the plug-in registry) are enough for the workbench to know that there is a view called "Hello View" available in the "Hello" category. It knows what class implements the view. But none of our code will be run until we decide to show the view.

If we choose the "Hello Greetings' view from the Show View list, the workbench will activate our plug-in, instantiate and initialize our view class, and show the new view in the workbench along with all of the other views. Now our code is running. 

Workbench with Hello World view

There it is, our first plug-in! We'll cover more specifics about UI classes and extension points later on.

Copyright IBM Corporation and others 2000, 2003.