jEdit: Java Programmer’s Text Editor

 

 

 

 

 

 

jEdit: Java Programmer’s Text Editor++

 

by Robert Swarr

AgoraLogos, LLC

February 3, 2003

 

Copyright ? 2003 Robert Swarr, AgoraLogos, LLC

This paper is distributed under the terms of the GNU Free Documentation License.

 

 

 

 


 

Introduction

The overview on the jEdit website homepage (http://www.jedit.org) states that “jEdit is a programmer's text editor written in Java...”  While this description is accurate, it understates jEdit’s capabilities. jEdit is more than a text editor, for you can install plugins that transform jEdit into a powerful IDE rivaling the likes of NetBeans and Eclipse.  The following sections in this paper elaborate on these two points. First, jEdit is a feature-rich text editor. Secondly, plugins transform jEdit into a powerful IDE.

Feature-Rich Text Editor

jEdit contains all of the features, both basic and advanced, you would expect to find in a text editor, and then some more. Yet, despite being feature-rich, jEdit has a easy learning curve. You can use the basic features before learning the advanced ones. The advanced features don’t get in your way when you first start to use jEdit because they are implemented unobtrusively – you can discover them gradually as you become more familiar with jEdit. For example, you can search a file by clicking on the binocular icon at the top of the display, and then as you become more proficient you can use the keyboard shortcuts and regular expressions to perform advanced search and replace operations on multiple files within a directory.

jEdit provides an abundance of features as shown in  the following list:

Text-Editing Features

·        Multiple and split edit windows

·        Keyboard shortcuts for all commands

·        Keyboard commands for manipulating words, lines or paragraphs.

·        Abbreviations – saves typing time for commonly used strings. For example, in Java mode, the abbreviation "sout" is defined to expand to "System.out.println()", so to insert "System.out.println()" in a Java source file, you only need to type "sout" followed by the control key together with a semicolon.

·        Copy and paste with an unlimited number of clipboards

·        Unlimited undo/redo.

·        Soft and hard word wrap.

·        Multiple selections and rectangular selection – you can select multiple areas of text or a vertical box of text.

·        Indent and marker based folding - lets you selectively hide and show sections of a source code file, replacing hidden sections with a single line that serves as an "overview" of that section. Folding can be performed on either leading white space on a line or explicit fold markers inserted into the text.

·        Markers – edit buffers can have any number of markers that point to specific positions in the file. These markers are persisted when the file is saved.

·        Auto-indentation of source code - the auto-indent feature inserts the appropriate number of tabs or spaces at the beginning of a line. Auto indent behavior is mode-specific so that in Java curly brackets and language statements are taken into account and indent is added and removed as necessary.

·        Syntax highlighting  – jEdit provides syntax highlighting for more than 80 file types including those of particular interest to Java programmers, notably Java, XML, and JSP. Comments and different syntax elements are displayed in different colors and fonts, improving the readability of file syntax.

·        Intelligent Bracket matching – jEdit provides assistance with one of the common problems in writing Java code – mismatched curly braces. Positioning the cursor after a bracket will highlight the corresponding closing or opening bracket.  jEdit uses intelligent bracket matching in that it only checks syntax tokens with the same type as the original bracket for matches and ignores curly braces in string literals and comments.

Powerful Search and Replace

·        Literal and regular expression search and replace

·        Multiple file search and replace - search the current file, multiple files or a whole directory

·        “Hypersearch” option displays all matches in a list

·        Incremental search finds occurrence of string as it is being typed in search bar. Typing Enter and Shift-Enter finds the next and previous occurrence.

·        BeanShell replace - the search string is replaced with the return value of a BeanShell script.

File Management

·        Any number of files can be opened concurrently

·        Custom File browser – used in open and save dialog boxes supports deleting and renaming files and creating directories.

·        Character encoding – jEdit supports extensive character encodings.  It uses the operating system's native default; MacRoman on the MacOS, Cp1252 on Windows, and 8859_1, but also support Unicode, UTF8 and international character sets such as KOI8_R for Russian text, Big5 and GBK for Chinese, and SJIS for Japanese In fact, it can use any character encoding supported by the Java platform.

 

Comprehensive online help - all jEdit features are well documented in the online help. The online help displays quickly when selected with the F1 key for from the toolbar.

Customization

·        editor settings can be configured on a global or file basis

·        configurable edit modes and syntax highlighting –  the syntax tokens of a file type are defined in XML files contained in the jEdit settings directory. The color and font of syntax tokens can be configured with an options setting.

·        Built-in macro language (BeanShell) allows automating complex editing tasks.  Macros can be recorded from user actions.

 

BeanShell

BeanShell merits a digression to explain its importance. First, it is a vigorous open source project in its own right. Pat Niemeyer wrote it while developing the examples for the O’Reilly book, Learning Java.  The program and source code is included with the book (by the way, I would recommend this book for those learning Java).  BeanShell is distributed under dual licensing terms, the Sun Public License and the Lesser Gnu Public License. It is used in other open source projects such as Ant. Check the BeanShell website (http://www.beanshell.org) for more information. Secondly, BeanShell plays an important role in the jEdit plugin architecture.  It is the “glue” that binds plugins to jEdit. The actions.xml file provides the main interface between a plugin and jEdit. The actions contained in this file are short BeanShell scripts that execute plugin methods. jEdit executes these BeanShell scripts when the corresponding plugin menu items are selected. The fact that BeanShell plays such an important role In jEdit demonstrates the vitality of the open source model. One open source project builds on another.

Plugins Transform jEdit into a Powerful IDE

 

The most salient feature of jEdit’s design is the extensible plugin architecture. The jEdit Plugin API provides an implementation-neutral framework for hosting a full range of applications from a Java compiler to a unit testing framework. For the record, a plugin is an application that loads and runs as part of JEdit and supplements jEdit’s features. Plugins can be downloaded and installed from within jEdit using the plugin manager feature that performs these tasks online with a point and click interface. Currently, the jEdit website lists more than 80 plugins that can be downloaded and installed. These plugins can transform jEdit into a full-featured IDE that can compile, debug, and unit test an application. And because you’re using plugins to add IDE functionality, you can customize your IDE based on your programming requirements and personal preferences.

 

An Example: My jEdit IDE

 

To make myself more effective I try to automate all of the tasks that I have to execute repeatedly during the development process. These tasks include compiling Java files, generating javadoc, building an application composed of multiple classes and packages, archiving the class files into a jar file, running unit tests, and so on.  So, I’ve installed plugins that automate all of these tasks with a point-and-click interface within jEdit. With my personalized jEdit IDE I can move efficiently through the development process concentrating on the programming rather than entering commands.

 

To create my jEdit IDE I downloaded approximately a dozen of the plugins listed at jEdit Plugin Central (http://plugins.jedit.org). The plugins I downloaded and installed are as follows:

 

  • AntFarm – The AntFarm plugin allows developers to build projects from within jEdit using Apache's Ant utility, displaying any errors in ErrorList. I use this plugin to execute Ant build scripts within jEdit.
  • InfoViewer – InfoViewer is a replacement for the built-in jEdit.  HelpViewer. It contains a mini web browser, but you can also configure it to use an external browser. I use this plugin to view javadoc that I generate with the JDocPlugin or javadoc selected with the JIndex plugin.
  • JavaStyle – The JavaStyle plugin encapsulates functions for formatting and beautifying Java source code. I use this plugin to provide consistent formatting for my Java files and generate  javadoc comment stubs, saving some keystrokes.
  • JBrowse – The JBrowse plugin allows for easy navigation of Java source code by providing a highly customizable tree-view of a file's classes, fields, and methods. I use this plugin to get a “macro” view of an individual Java source file and to navigate through the file – it saves a lot of scrolling.
  • JCompiler – The JCompiler plugin allows for in-process compiling of Java source files and packages. I use this plugin to incrementally compile a Java class while I’m writing it.
  • JDocPlugin –The JDocPlugin provides configuration and persistance of Javadoc command line arguments and execution of the utility within jEdit (I’m the author of this one). I use this plugin to generate javadoc as I’m writing the javadoc comments. Then, I view the generated javadoc within jEdit using the InfoViewer plugin.
  • JIndex – The JIndex plugin enables jEdit to show the Javadoc API html documentation for the currently selected word, with a single key press, in a browser of your choice. The Java API is so large that remembering all of the classes, methods and arguments is an impossible task. I need to refer to the Java API javadoc frequently.  This plugin allows you to quickly view the API javadoc of a method within jEdit (InfoViewer plugin).
  • JSwatPlugin – The JSwatPlugin integrates the JSwat Java debugger into jEdit. Includes JSwat 2.8 in plugin version 1.2 or higher; JSwat 1.4 in earlier versions. I use this plugin for those times when you need to step through the code.
  • ProjectViewer – The ProjectViewer plugin provides an interface for managing a "project", i.e. a related group of source files. I use this plugin to get a “macro” view of a project, load files, and build a project with an Ant script.
  • XML – The XML plugin provides features for editing XML and HTML files, such as validation against a DTD, display of the element tree in a dockable window, and tag and entity completion. I edit XML files frequently and I have trouble matching begin and end tags. The XML plugin helps with editing and navigating through XML files.

 

 

In addition to the above list there are some dependent code plugins that are used such as Console, ErrorList, and Common Controls. If you use the Plugin Manager to download the plugins, it will take care of these dependencies for you. If you download the plugins manually and miss one of the dependencies, jEdit will handle the error gracefully and notify you of the missing plugin with a popup dialog. No problem. Good design.

 

Just in case you’re wondering, performance with the above installed plugins is snappy.  When you press a key something happens (other than display of the hourglass). Program load times are quick for a full-featured IDE. As a matter of fact, the performance is positively snappy when you compare it to the load times of other IDEs like NetBeans. Faster processors, Swing improvements, Hotspot technology, and good design have ameliorated the performance problems of Java user interfaces of a few years ago.

 

I’m not claiming that the above list is the best selection of plugins.  It’s just my selection of plugins and shows how you can transform jEdit into a powerful IDE.

 

My Typical Project Scenario

 

Now, how do I use all of the plugins? The following is a synopsis of my typical project scenario. These are the typical sequence of steps I perform when I create an application with my jEdit. IDE.

 

1.

Create a project using the ProjectViewer plugin.

2.

Create a Java source file and add it to the project.

3.

Create XML configuration files, view them with the XML plugin, and add them to the project.

4.

Enter method declarations and compile incrementally with the JCompiler plugin. View errors on the Console plugin, and correct errors and recompile.

5.

Reformat the Java source file and add Javadoc stubs with the JavaStyle plugin. Write the Javadoc comments for the class and methods.

6.

Generate Javadoc with the Javadoc plugin, and view the generated HTML with the InfoViewer plugin.

7.

Enter code within methods, compile with JCompiler, and correct syntax errors.

8.

Write a  JUnit test class and run the JUnit test with the JUnit Plugin.

9.

Repeat the above for all of the classes and packages in the project. 

10.

Create an Ant build script for the project and place it at the root level of the project.

11.

Build the application with the AntFarm plugin.

12.

Run the application. If necessary, debug it with the JSwat Plugin.

13

Refactor, refactor, and refactor: navigate through the Java source files in the project viewer interface and pull common code into new classes (go back to step 2).

 

Conclusion

 

You can use jEdit as a programmer’s text editor, and it is rich with text editor features. The performance is snappy, and it is as at least as reliable as proprietary commercial editors.  If you want something more than a text editor, then you can download the appropriate plugins and transform it into a powerful IDE that allows you to compile, document, debug, build and test within jEdit. Add a handful of plugins and It becomes much more than a programmer’s text editor.

 

What is more, jEdit demonstrates the vitality of the open source model. It has a healthy community of well over three thousand users that support its ongoing development. Its development is rapid, and the software is both sophisticated and reliable. As Eric Raymond states it so well, “many eyeballs tame complexity”.

 

Resources

 

jEdit website:           http://www.jedit.org

jEdit 4.0 User’s Guide: jEdit download page

Beanshell website:          http://www.beanshell.org

The Cathedral and the Bazaar, Eric Raymond: http://www.catb.org/~esr/writings/cathedral-bazaar/

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值