June 24, 2018
Hot Topics:

A First Look at Eclipse Plug-In Programming

  • February 23, 2004
  • By Koray Guclu
  • Send Email »
  • More Articles »

2.2. Creating a Plug-In Project

Developing a plug-in project is different than developing a normal application. A plug-in project needs to be created before starting to develop a project. To create a plug-in project, choose "File-> New -> Project...-> Plug-in Project".

Figure 9. Creating a Plug-in project

Give a project name on the second page. Accept the default values on the third page. On the fourth page (see Figure 10), select "Create a plug-in project using a code generation wizard" and "Hello, World". Click Finish on the fifth page.

Figure 10. Plug-in code generator

We have created a plug-in project successfully. The structure of the project can be seen below. The plug-in creation wizard has created one plug class, one action class, and the necessary resource files.

Figure 11. Plug-in Structure

To test your project, you need to run the project as a Run-time Workbench by using "Run->Run As->Run-time Workbench". A new Eclipse instance will be started and your plug-in will be ready to use in this instance. The running instance will contain the HelloWorld Plugin and the toolbar contribution of the plug-in will be shown. Figure 12 shows the second running instance of the Eclipse application.

Figure 12. Toolbar contribution

Should you need to see the loaded plug-in, you can use "Help->About Eclipse Platform->Plug-in Details". You can find the HelloWorld plug-in in the list as well, which means that our plug-in is loaded properly.

Figure 13. A list of loaded plug-ins

3. Inspecting the generated source

3.1. Plug-in Manifest file

Eclipse doesn't load all the plug-ins until they are needed. The plug-in manifest file provides Eclipse with a definition of the plug-in. The plug-in manifest doesn't contain any internal details. It is only a shadow of the real plug-in implementation.

Figure 14. Plug-in manifest file

Eclipse reads all the plug-in manifest files at startup and keeps them in the plug-in registry. When the plug-in required, it loads and instantiates the plug-in.

3.1.1. Plugin tag
 Source 1. plug-in.xml
   <?xml version="1.0" encoding="UTF-8"?>
     name="HelloWorld Plug-in"
  provider-name="Koray Guclu"

The code listing above shows the manifest file of the hello world application. It is an XML file. It contains information about the plug-in.

The plugin id is defined. The plug-in id is must be unique. But, the name of the code listing tells that plug-in's unique id is de.korayguclu.eclipse. The id must be unique, but the name of the plug-in can be anything.

Plug-ins can have versions and other plug-ins can depend on a specific version of another plug-in.

The provider name of the plug-in is displayed on the plug-in listing window. Refer to Figure 12.

The class name is import. It defines the plug-in class. The class must comply with the definition of a plug-in. Just like a gear on Figure 14, in order to run properly with the existing system, a plugin must also conform to the rules defined by the system. For that reason, plug-in class extends from org.eclipse.ui.plugin.AbstractUIPlugin.

 Source 2. HelloWorldPlugin.java
   package de.korayguclu.eclipse;
   import java.util.*;
import org.eclipse.core.resources.*;
   import org.eclipse.core.runtime.*;
import org.eclipse.ui.plugin.*;
   public class HelloWorldPlugin
       extends AbstractUIPlugin

Source 2 above shows the Java source of the plug-in. As you can see, the HelloWorldPlugin class extends the AbstractUIPlugin class.

Figure 15. HelloWorldPlugin inheritence

3.1.2. Runtime tag

Runtime tag defines the libraries required by the plug-in execution at runtime. If you need to use other libraries in your plug-in, you can copy them under the root directory of the plug-in and write your plug-in name in the runtime tag.

 Source 3. plug-in.xml, runtime tag
  <library name="eclipse.jar"/>


 HelloWorld plugin's class files are in the eclipse.jar file. They are required at runtime. For that reason, we have to at least write the name of the jar file containing the plug-in class files here.

Page 4 of 5

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.


We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date