Click here to Skip to main content
15,885,278 members
Articles / Programming Languages / Java
Tip/Trick

How to Create Your Own Eclipse IDE Plug-in

Rate me:
Please Sign up or sign in to vote.
4.00/5 (5 votes)
4 Apr 2015CPOL3 min read 96.6K   3   1
Development tools development

0. Goal

Eclipse plugins are Java libraries that are running by Eclipse and can use Eclipse IDE APIs to extend Eclipse's functionality via many different ways.

Plugins allow you to realize your own menus and toolbar items, new features to code editor, new project and item templates, and your own WYSIWYG editor on Eclipse IDE base. Eclipse IDE + Your Plugins = Your Own IDE.

For example:

  • Eclipse IDE + ADT Plugin = Eclipse+ADT, IDE for Android applications
  • Eclipse IDE + Blackberry Plugins = Momentics IDE, IDE for BlackBerry applications
  • Eclipse IDE + Titanium Plugins = Titanium IDE, IDE for mobile applications

Let's start writing Eclipse plugins today! At first, let's write a simple plugin that adds a few menu items and subitems.

1. Tools Preparation

At first, you should check if Eclipse contains PDE plugin = allows plugin development.

  1. Run the Eclipse.
  2. Go to File -> New -> Projects...
  3. Check if there is a Plug-In development group. If there is none, you should firstly install PDE plugin into Eclipse.

Go to Help menu. If there are no "Eclipse Marketplace..." items, you at first must install Marketplace client. Else, you can go to PDE plugin installation.

Marketplace Client Installation
  1. Go to Help -> Install New Software...
  2. Click Add... 
  3. Set Location field to http://download.eclipse.org/releases/indigo and press OK. Wait while Eclipse will fetch an Indigo repository items.
  4. Expand the General Purpose Tools group and check Marketplace Client. Press Next.
  5. And Next, again. 
  6. Accept license terms, and press Finish.
  7. Wait while Marketplace is being installed... And restart the Eclipse. Now, you can go to install PDE plugin.
PDE Plugin Installation
  1. Go to Help -> Eclipse Marketplace...
  2. Print PDE to Find field, and press Enter.
  3. Press the Install button on "Eclipse PDE" item.
  4. Press Next.
  5. Accept license terms and press Finish.
  6. Wait while PDE is being installed... And restart the Eclipse. Now, you can go to create your own plugin.

2. Create a Plugin

  1. Run the Eclipse.
  2. Go to File -> New -> Project...
  3. Go to Plug-In development -> Plug-in Project. Press Next.
  4. Type some project name. It's recommended to use org.*.* format, i.e. org.plugin.helloworld.
    Press Next.
  5. (Optionally) Specify Plug-In Provider Name (print your brend nick or your company brand), and Plug-In Name. Press Next.
  6. Select a "Hello, World" plug-in template. Press Finish.

3. Debug your Plugin

Press a Run button. You'll see a new Eclipse window with "Sample Menu" with "Sample Action" item.

Click this item, and you'll see a message box with "Hello, Eclipse world".

4. Install your Plugin to Eclipse

  1. Right-click your plugin project in Package Explorer window.
  2. Press Export... in shown context menu.
  3. Select Plug-In Development -> Deployable plug-ins and fragments (or Deployable plug-ins and fragments directly in old Eclipses).
  4. Use it to get plugin JAR file, i.e. org.plugin.helloworld_1.0.0.201504042200.jar
  5. Close Eclipse. Copy this JAR to eclipse/plugins/ path. Run Eclipse again.
  6. Now you'll see "Sample Menu" with "Sample Action" item on ever Eclipse run.

Note: You can write an automatic installer for your plugin for Windows users, or publish your plugin to... the Eclipse Marketplace! :))

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions

 
QuestionSimple and clear Pin
Member 1471477412-Jan-20 23:58
Member 1471477412-Jan-20 23:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.