Using a Text Editor

Unlike more sophisticated Java development tools, the Java Development Kit does not include a text editor to use when you create source files. For an editor or word processor to work with the kit, it must be able to save text files with no formatting. This feature has different names in different editors. Look for a format option such as one of the following when you save a document or set the properties for a document:

  • Plain text
  • ASCII text
  • DOS text
  • Text-only

If you're using Windows, there are several editors included with the operating system. Windows Notepad is a no-frills text editor that only works with plain-text files. It can handle only one document at a time. Choose Start, All Programs, Accessories, Notepad to run it on Windows XP or choose Start, Programs, Accessories, Notepad on other Windows systems. Windows WordPad is a step above Notepad. It can handle more than one document at a time and can handle both plain-text and Microsoft Word formats. It also remembers the last several documents it has worked on and makes them available from the File pull-down menu. It's also on the Accessories menu along with Notepad. Windows users also can use Microsoft Word, but must save files as text rather than in Word's proprietary format. (Unix and Linux users can author programs with emacs, pico, and vi; Macintosh users have SimpleText or any of the aforementioned Unix tools available for Java source file creation.) One disadvantage of using simple text editors such as Notepad or WordPad is that they do not display line numbers as you edit. Seeing the line number helps in Java coding because many compilers indicate the line number at where an error occurred. Take a look at the following error generated by the JDK compiler:

Palindrome.java:2: Class Font not found in type declaration.


The number 2 after the name of the Java source file indicates the line that triggered the compiler error. With a text editor that supports numbering, you can go directly to that line and start looking for the error. Usually there are better ways to debug a program with a commercial Java coding package, but kit users must search for compiler-generated errors using the line number indicated by the javac tool. This is one of the best reasons to move on to an advanced Java development program after learning the language with the Java Development Kit.

Did you Know?

Another alternative is to use the kit with a programmer's text editor that offers line numbering and other features. One of the most popular for Java is jEdit, a free editor available for Windows, Linux, and other systems at the website http://www.jedit.org. I can personally recommend UltraEdit, an excellent programmer and web designer's editor that sells for $35 at the time of this writing. To find out more and download a trial version, visit the website http://www.ultraedit.com.


      
Comments