# jEdit 2.6 User's Guide

Next, Prev

## Chapter 11. Developing Plugins

# The EditPlugin Class

At the heart of every plugin is an implementation of the `org.gjt.sp.jedit.EditPlugin` class. It registers the plugin's actions with jEdit, takes care of setting up the plugin's menus and menu items, and so on. When a plugin JAR is loaded, jEdit scans for any class files whose names end with `Plugin` (for example, `FooPlugin`). Those classes are instantiated and added to jEdit's plugin list.

#### EditPlugin class

    public abstract class EditPlugin
    {
            public void start();
            public void stop();
            public void createMenuItems(Vector menuItems);
            public void createOptionPanes(OptionsDialog optionsDialog);
    }

#### EditPlugin.start() method

``void start`(void);`

This method is responsible for adding actions and edit modes to jEdit, and doing other initialization tasks. It is called at the end of the jEdit startup sequence, after all plugins are loaded (so by the time this method is called, classes from other plugins are available, and so on). Most plugins will want to override this method and do some initialization.

#### EditPlugin.stop() method

``void stop`(void);`

This method is called just before jEdit exits. Overriding it is rarely necessary.

#### Example

Here is the source file (which should be named `HelloWorldPlugin.java`) for a simple plugin:

    import org.gjt.sp.jedit.*;
    import java.util.Vector;

    public class HelloWorldPlugin extends EditPlugin
    {
            public void start()
            {
                    jEdit.addAction(new hello_world());
            }

            public void createMenuItems(Vector menuItems)
            {
                    menuItems.addElement(GUIUtilities.loadMenuItem("hello-world"));
            }
    }

Home, Up
Prev: Developing Plugins
Next: Plugin Properties