Step by step in Eclipse IDE
- Create new Eclipse plug-in: File -> New -> Other -> Plug-in Development -> Plug-in Project
- Add dependency: MANIFEST.MF -> Dependencies tab -> Add -> org.eclipse.ui
- Add extension point org.eclipse.ui.menus: plugin.xml -> Extension -> Add -> org.eclipse.ui.menus
- Right-click -> New -> menuContribution
- Enter locationURI: menu:file
- Right click -> New -> command
- Enter commandId: tk.urbas.eclipse.sample.sampleCommand
- Enter label: Sample Menu Item
- Enter locationURI: menu:file
- Right-click -> New -> menuContribution
- Add extension point org.eclipse.ui.commands: plugin.xml -> Extensions -> Add -> org.eclipse.ui.commands
- Right-click -> New -> command
- Enter id: tk.urbas.eclipse.sample.sampleCommand
- Enter label: Sample Command
- Right-click -> New -> command
- Add extension point org.eclipse.ui.handlers: plugin.xml -> Extensions -> Add -> org.eclipse.ui.handlers
- Right-click -> New -> handler
- Enter commandId: tk.urbas.eclipse.sample.sampleCommand
- Enter class: tk.urbas.eclipse.sample.SampleHandler
- Click class link and create class
- Provide sample implementation of the handler class implementing org.eclipse.core.commands.IHandler or extending org.eclipse.core.commands.AbstractHandler
- Right-click -> New -> handler

Menu, command, handler
MANIFEST.MF
Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Sample Handler Bundle-SymbolicName: tk.urbas.eclipse.sample;singleton:=true Bundle-Version: 1.0.0.qualifier Bundle-Vendor: urbas.tk Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: org.eclipse.ui
plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:file">
<command
commandId="tk.urbas.eclipse.sample.sampleCommand"
label="Sample Menu Item"
style="push">
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="tk.urbas.eclipse.sample.sampleCommand"
name="Sample Command">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="tk.urbas.eclipse.sample.SampleHandler"
commandId="tk.urbas.eclipse.sample.sampleCommand">
</handler>
</extension>
</plugin>
Handler – sample implementation showing a message
package tk.urbas.eclipse.sample;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
public class SampleHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
MessageDialog.openInformation(Display.getDefault().getActiveShell(),
"Sample Handler", "Sample Handler");
return null;
}
}