Using Java Tools in TextPad

For Java Programmers

Set up TextPad

  1. From the TextPad menu, select Configure/Preference/Tools
    TextPadPreference
    Note: If you don't see these three tools listed, click on the word Tools and a dialog box will open. Look for the "Add" button on the right. These three tools will be listed when you click on "Add".
  2. Click on Compile Java tool:


Compile Java Tool Dialog Box


Notice how this sets up Java to run the Java compiler named javac.exe
using the file that is currently active in TextPad.

TextPad will open up a DOS command window and run javac automatically and return to the source code if everything compiles correctly. If there are errors it will open up a new text window showing the errors. (You can double click on the errors to jump back into the source code where the problem is.)


Preferences for TextPad tools

Do the same thing for "Run Java Application" setting up the fields to match the graphic above.
This will set up TextPad to run the java.exe with the class name of the file that was compiled.

For example: If your class is named HelloWorld.java,
Textpad will run the following command in a DOS window: javac HelloWorld.java
Which creates a file named HelloWorld.class
Run Java Application will run the following command in DOS: java HelloWorld using the file HelloWorld.class that was created by javac.

 

Use the TextPad Tools

Always save a program before compiling and running it.

To compile a program, select Tools/Compile Java from the TextPad menu.

To run a program, select Tools/Run a program.

Be an efficient programmer, use hot keys!
CTL s
- saves the program
CTL 1 - compiles the program
   If errors, dbl click on the first error to jump to the source
CTL 2 - runs the program (only works on the class that was successfully compiled.)

Install TextPad add-on for Java Syntax

  1. Go out to the TextPad site: http://textpad.com/add-ons/index.html
  2. In the sub-menu (under "Add-Ons") look for "Syntax Definitions"
  3. Choose the H-M alphabet and go to Java 2 ( the marketing name for Java).
  4. Save the zip file in a directory that you can find.
  5. Unzip the file into the C:\Program Files\TextPad 4\Samples (or the samples folder where ever you have TextPad installed.)

When TextPad sees the .java extension it will use this syntax coloring scheme.

Important:
Always surround your file name with quotes to keep textpad from automatically adding on the .txt extension. Java programs will not compile if they are named MyFile.java.txt!

Add Quotes in TextPad

To set your own computer so TextPad does not automatically add a TXT extension:

  1. In TextPad select Configure/Preferences/File from the menu.
  2. Delete the "txt" in the default field.
  3. Leave this field empty.

Default extension settings


Peter K. Johnson - South Central College - N Mankato, MN 56001 - peter.johnson@southcentral.edu

http://southcentral.edu/cc