Java: TextPad Editor
Downloading TextPad
A free, trial version of TextPad can be downloaded from
www.textpad.com .
Installation
- Install a JDK, downloadable from java.sun.com.
- Install TextPad.
Preferences
There no critical preferences that need changing, but they can be set by selecting the
Configure > Preferences
menu item.
Some things you might wish to set:
- Folders
- Set the
Startup
directory to where
your files are normally located.
- Document Classes > Java > Tabulation
- Set the default tab spacing to 4, indent size to 4,
and check both the Convert new tabs to spaces and
Convert existing tabs to spaces when saving files.
Tabs should generally not be used in programming because
the size of tabs is not universal so someone else looking
at your program will often see a mess
Entering. compiling, and executing your Java program in Textpad
- Type or paste your Java program source code into the large text pane.
- Putting the programs directly on your desktop is not a good idea.
Create a folder / directory for all of your cmis102a work in it,
and a separate directory for each program. The little bit of extra work to
create separate directories prevents unwanted interactions between old and new programs.
It can save endless hours of frustration. This is not just an academic neatness obsession -
it comes from seeing students who were unable to complete their assigments because of old-file pollution.
- Save it in a file with EXACTLY the same name as the "class" with an extension of ".java".
The "class" name is not the name of the course you're taking, but the name following the word "class" in the Java source code)
If the program has this class in it
class InitialTest {
. . .
It must be saved in a file called InitialTest.java .
Save the file in a directory for this program.
- Compile (perform the translation process from source code to machine code)
by selecting the Tools > Compile Java menu item.
If there are errors (there usually will be at first), you can go back and
forth between the "Command Results" and the source code by clicking on each of
them in the top left pane. Continue with this process until it compiles
correctly.
- Run the program by choosing Tools > Run Java Application menu item.
You will be using one of these to styles of interaction (Input-Output) at
the beginning.
- Console Ouput (System.out.println(...)).
This will open a DOS Command Window and you will see your text output,
followed by "Press any key to continue . . .". Your program is done!
- Dialogbox Output (JOptionPane.showMessageDialog).
A dialog box will appear in the middle of your window. Click OK to close it.
TextPad FAQ
- Q: TextPad can't find the Java compiler. What's wrong?
A: When TextPad can't find the Java compiler, there are two common causes.
- You installed TextPad before the Java compiler. You MUST install Java first.
Uninstall TextPad (from the System control panel) and reinstall it.
- You didn't install the Java JDK, maybe you only have the Java JRE.
If you installed Java 5 is should install by default in
C:\Program Files\Java\jdk1.5.0_01
There will also be a "jre" (Java Runtime Environment),
which is appropriate, but be sure there is a "jdk" (Java Development Kit).
- Q: Can I run my Java program like a normal application?
A: No. TextPad translates the .java files into
.class files which can not be run by double-clicking
them. Some IDE's (eg, NetBeans) will produce double-clickable
.jar files, and there are programs which will package
your Java files into a .exe file.