Power Java programming—free!

Build an open source IDE with jEdit

Sometimes the best things in life are free, like fresh air and sunshine, but not software. Until recently, a professional-grade IDE could have cost hundreds or even thousands of dollars. However, after Linux entered the marketplace, open source software proliferated and became competitive with commercial software. Today, open source development tools are as free as fresh air and sunshine, and just as plentiful.

For example, the jEdit programmer's editor is an open source utility with advanced editing features. Using jEdit plug-ins, you can integrate open source development tools such as CVS (Concurrent Versions System), Ant, and JUnit within jEdit's graphical user interface (GUI). This article shows you how to transform jEdit into an IDE comparable to proprietary software. In this article, I use the term open source software instead of free software. To set the record straight, "Sidebar 1: Open Source Software = Free Software" explains the similarities and differences between open source and free software.

IDE features

The first step in building an IDE is answering a simple question: what features should the IDE support? Many developers request features in the following list. These requirements may be the same for you:

  • Small, fast, intuitive, but powerful programming editor: it starts up and responds quickly; you can use it without spending hours reading documentation; and it has powerful features such as advanced search and replace
  • Source code beautification: configurable, programmatic formatting of Java source files to a consistent standard
  • Class browser: tree-structured view of the methods, data members, and inner classes in a Java source file and point-and-click navigation through the file
  • Project view: tree-structured view of a project's files and point-and-click navigation through the project
  • Version control: integration with CVS with a graphical interface
  • In-process compilation: compilation of a Java class in the current edit buffer
  • Unit-testing framework: integration with JUnit to run automated regression tests within the IDE
  • Build management: integration with Ant to run build scripts for a project within the IDE
  • Integrated debugger: when code behaves badly and you don't know why, having a debugger in your toolkit is a blessing
  • Integrated Javadoc generation and viewing with a graphical interface

You might want to add additional features to the above list based on your requirements.

Build the jEdit IDE

Once you've defined your requirements for an IDE, download and install the software. If you don't have a Java SDK, download one. The development tools need jar and executable files included in the SDK, but omitted from the JRE (Java Runtime Environment).

Installing jEdit is as simple as downloading and running an executable jar file. From the jEdit project homepage, select the Quick Start page and follow that page's directions. Read the installation instructions for your operating system on the download page. To run jEdit, use the Java application loader (javaw) in the SDK, not the JRE, since the development plug-ins will not work properly with the JRE.

Note: Due to strong corporate backing, NetBeans and Eclipse have received much more press coverage than jEdit. If you're wondering why someone would pick jEdit over NetBeans or Eclipse, see "Sidebar 2: jEdit Versus NetBeans and Eclipse."

Downloading jEdit plug-ins is equally simple. Using the Plugin Manager, simply point and click—no analysis required. The Plugin Manager resolves dependencies and automatically downloads any jar files required by the plug-ins you select. The following is a list of the plug-ins that provide the features discussed earlier:

  • AntFarm: integrated graphical Ant build manager
  • JavaStyle: Java code beautifier and template Javadoc comment generator
  • JBrowse: class browsing of a Java source file
  • JCompiler: in-process compiler for Java files in the edit buffer
  • GruntspudPlugin: a graphical CVS client that supports most CVS commands and many connection methods, including local, pserver, and ext
  • JIndex: with a single key-press, shows Javadoc API HTML documentation for a highlighted word
  • JUnitPlugin: integrated graphical JUnit test runner
  • ProjectViewer: tree-structured view of related project files
  • Swat: integrated graphical interactive debugger
  • JDocPlugin: integrated graphical Javadoc generation

You might want to install additional plug-ins based on your requirements (the jEdit Website lists 80 plug-ins). Also, jEdit automatically downloads some plug-ins such as the Common Controls and Console plug-ins to resolve dependencies between plug-ins.

To install plug-ins, from the jEdit menu bar, select Plugins, then Plugin Manager. Next, click the Install Plugins button at the bottom left of the Plugin Manager dialog box. On the Install Plugins dialog box, check the boxes for the plug-ins you want to download (see Figure 1); check the box labeled Download Source Code; select the radio button labeled Install In User Plugin Directory; and click the Install button. The plug-ins should download in a few minutes (assuming a high-speed Internet connection). Restart jEdit and you're ready to start programming.

Figure 1. Install plug-ins

Configure and use the jEdit IDE

After installing jEdit and the plug-ins, configure your IDE using the Utilities command from the Global Options menu. Most plug-ins require little if any configuration. If you have any questions about configuring a plug-in, select the Help menu—interactive help is part of the plug-in architecture.

To improve ease of use, you'll want to "dock" frequently used plug-ins such as Gruntspud, ProjectViewer, JBrowse, AntFarm, and JUnit. Plug-ins can either float or dock on one of the four sides of the jEdit window. Docking a plug-in allows you to minimize it to the side of the edit window and launch it quickly by clicking on the plug-in's tab. To configure docking, select Utilities, Global Options, jEdit, Docking; set the docking position for these plug-ins to the location you prefer; and click the Apply button. Tabs for these plug-ins will appear on the jEdit window side that you picked (see Figure 4).

You'll also want to configure the Console plug-in to display a console toolbar for entering operating system commands within jEdit. To configure the console toolbar, select Utilities, Global Options, Plugins, Console, General, and check the Console Tool Bar box.

I next describe configuring and using several of the more important plug-ins: Gruntspud, ProjectViewer, AntFarm, and JUnit. The rest require little if any configuration, and using them is intuitive.


Gruntspud is a CVS client, so knowledge of CVS is a prerequisite for using it. The following example uses a local CVS directory to create a working directory of the downloaded JDocPlugin source code in a directory named \javapkgs\src (I refer to the JDocPlugin project in this article's later sections).

First, select the Gruntspud connection dialog box from Global Options and configure a local connection. For my configuration, I used the name localCVS, for a local type and a repository path of C:\CVS. Click the Add button on the Add Connection dialog box and the OK button on the Global Options dialog box to store the configuration.

Next, import the JDocPlugin project into the local CVS repository. To import this project, select Plugins, then Gruntspud; click the All Tools icon on the toolbar's left-hand side (an image of a crossed wrench and screwdriver); and select Create, then Import to display the Import dialog box. On the Import dialog box, complete the General pane as shown in Figure 2; enter the version message on the Message pane; click the Rescan button on the Files pane; and then click the Import button.

Figure 2. Gruntspud Import dialog box

Finally, create a CVS working directory by checking out the JDocPlugin module from the CVS repository. Select Create, then Checkout to display the Checkout dialog box. Navigate to \javapkgs\src and set the current directory to the JDocPlugin directory's location. Select the General tab, type JDocPlugin for the module name and checkout name, and click the Checkout button. After the checkout executes, Gruntspud displays the CVS working copy's status. Click the Explorer tab in Gruntspud, select one of the Gruntspud files, then right click and select Status. Figure 3 shows the Gruntspud display of a CVS working directory.

Figure 3. CVS working directory


Use the ProjectViewer plug-in to view and edit the JDocPlugin source files. First, create a JDocPlugin project. Select the ProjectViewer tab, left click the All Projects folder and select Add Project. Type the project name JDocPlugin. Open the JDocPlugin root directory that you created in the CVS configuration (/javapkgs/src). Highlight the JDocPlugin directory and then click the Open button. Click OK and select Import All Files. jEdit will add the JDocPlugin source files to your project view. Now you can edit the project's files by double-clicking their icons. Open the jdoc directory and double-click the JDocPlugin.java file. Figure 4 shows the JDocPlugin project's ProjectViewer display.

Figure 4. ProjectViewer


For any project with more than a few Java files, you'll want to use Ant to build the application. To use Ant with the JDocPlugin project, you need to configure AntFarm to use JDocPlugin's build file. First, select Utilities, then Global Options to display the Global Options dialog box. On the Global Options dialog box, select AntFarm, then Build Options. Set the radio button labeled Run Ant Targets In The Same JVM and check the box labeled Load Build Files From The Project Viewer Plugin. Then click the OK button.

To run a build for the JDocPlugin, change the classpath in the build.xml file to match your environment. Select the ProjectViewer tab and double-click the build.xml icon to edit the build.xml file. Locate project.class.path and change the jar files' locations to the path on your system (either the jEdit installation directory or the user directory). Use the following as a guide:

   <property name="jedit.install.dir"
      value="/Program Files/jedit 4.1/jars"/>
   <property name="user.install.dir"
      value="/Documents and Settings/Bob/.jedit/jars"/>
   <path id="project.class.path">
      <pathelement location="${user.install.dir}/ErrorList.jar"/>
      <pathelement location="${user.install.dir}/Console.jar"/>
      <pathelement location="${jedit.install.dir}/jedit.jar"/>

Now click the AntFarm tab and you should see an icon for the JDocPlugin build file. Open it and select the Compile target. Click the green arrow icon to execute the target. Ant will write the build output to a jEdit console window.


JUnit is a unit test framework that facilitates automated testing. You can improve software quality and shorten development time if you run automated unit tests to verify correct operation of modified code. Use the JDocCommandTest class (in the jdoc.options package) to familiarize yourself with the JUnit plug-in's operation. This class lacks a main() method that calls a JUnit test runner because the JUnit plug-in performs this task.

Configure the JUnit plug-in to run the JDocCommandTest JUnit test class that you compiled in the AntFarm example. Click on the JUnit plug-in tab and click the grid icon to display the JUnit classpath dialog box. Enter JDocCommandTest's path and click OK. Next, type the full class name, jdoc.options.JDocCommandTest, on the JUnit dialog box's first line and press Enter. If you've configured the JUnit plug-in correctly, the dialog will display a green bar indicating a successful JUnit test. Note that you can select from many JUnit tests by clicking on the folder icon and selecting the desired test.

Extreme jEdit

Now that you've built an IDE with source code version control, automated build management, and unit testing, how do you use it? It just so happens that these features are required for an extreme programming (XP) approach. Although XP is a software development methodology that doesn't depend on any particular tools, the right tools are helpful.

Gruntspud integrates a CVS client into jEdit and facilitates collective code ownership and iterative programming. XP programmers share the entire codebase and develop software in many small steps. CVS allows multiple programmers to synchronize concurrent changes to the same file.

The AntFarm plug-in integrates Ant into jEdit and facilitates continuous integration. Ant provides an automated and consistent build process that eliminates error-prone manual processes. Store the build script and required jar files in the version control and build the application from the version control to guarantee all developers a consistent environment. Ant encourages frequent builds, which is fundamental to the XP approach.

The JUnit plug-in facilitates test-driven development. Automated unit testing represents one of XP's most important ideas. When you write code, you also write a unit test for the code. When the code passes the test, it is complete. Automated regression testing is a core concept of the XP approach.

1 2 3 Page 1