Installing and Using TextPad

From CompSciWiki
Revision as of 12:08, 21 August 2014 by Tandres (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

COMP 1010 Home > Getting Started


Some students may wish to program using TextPad in Windows (instead of DrJava). The following instructions are for students using TextPad with the JDK. There is no penalty for choosing to use TextPad instead of DrJava.

Installing TextPad

After installing the JDK you are ready to install a development environment. A development environment is where you do the actual writing and running of your programs. Some students using Windows install the textpad development environment, as TextPad is available on lab computers. Note that TextPad is shareware, and you are expected to purchase a copy if you intend to keep on using it.

IMPORTANT: Install the JDK first! If you install it after you have already installed TextPad, you will need to manually set up TextPad to compile and run Java programs.

Below are the links to download TextPad and installation instructions.

Here's a short Guide to TextPad.

Common Problems with JDK and TextPad

Warning! This section is based on problems encountered in about 2011. Since then, DrJava has been used in most classes. Note that the version of TextPad on lab computers is 5.4. The current download version of TextPad is 7 (as of 2014).

TextPad Does Not Have the Options to Compile and Run, or These Options are Present But do Not Work

NEW!*** When you were installing JDK did you chose 'Windows' or 'Windows 64-bit'? If you chose Windows 64-bit, uninstall JDK, then reinstall it, choosing just 'Windows'. There is a problem with the Windows 64-bit version of JDK, QuickTime, and TextPad. The easiest solution is to just go back to the 32-bit version of JDK.

First, make sure that you have installed the JDK. If it is not installed when you install TextPad, TextPad will not be able to set up the compile and run commands. Then you have two options: 1) Re-install TextPad or 2) Add JDK commands using the menu. There is also a third option involving changes to Windows configuration that you may find on the internet, but this option varies somewhat depending on your version of Windows, so we will address only these two choices here.

STEP 1: Add JDK commands using the TextPad menu In TextPad, follow these steps if the compile and run options do not appear (see below if they appear but do not work):

  1. Click on Configure, then choose Preferences
  2. Select Tools (from Preferences dialog box)
  3. Click Add
  4. If "JDK Commands" appears on the drop down menu, select it and click Apply or OK. (See picture below.)

Javacommands.jpg

STEP 2: Reinstall TextPad Uninstall Textpad, and install it again. To uninstall Textpad:

  1. Click on the Start button at the bottom left corner of the screen.
  2. Click Control Panel
  3. Double click on Add or Remove Programs (the name is slightly different in some versions of Windows)
  4. Scroll down the list until you find Textpad
  5. Click on the Change/Remove button
  6. Follow the prompts to uninstall Textpad

STEP 3: If you're still reading, it probably means you've reinstalled TextPad, then tried to add the "JDK Commands" and they still do not appear. Next? Install working compile and run commands from scratch:

  1. Click on Configure, then choose Preferences
  2. Select Tools (from Preferences dialog box)
  3. Click Add
  4. Choose Program... and then use the file selection window that opens up to find the javac command. It will be in C:\Program Files\Java\jdk...\bin (where the ... means some version number). Click on javac and then click on Open. A new tool called Javac should appear in the list of tools. Click on Apply to make it permanent. Javac is your new compiler tool.
  5. Create a run tool in the same way, but this time select the file java instead of javac. The new run tool will be called Java. Make sure you click on Apply.
  6. Then click on the + beside Tools in the Preferences dialog box to show Javac and Java below it. Select each one in turn and make sure the rest of the settings are correct.
  7. Javac: Parameters should be $File and Initial Folder should be $FileDir. You may want to click on "Capture Output" and/or "Sound alert when completed" as well.
  8. Java: Parameters should be $BaseName and Initial Folder should be $FileDir. You may want to click on "Capture Output" and/or "Sound alert when completed" as well. It should look something like the following:

JavaTool.png


Textpad doesn't use colour for key words

First, make sure you have the JDK commands under the tool menue (see above help item). Next, turn on the Java syntax highlighting:

  1. Click on Configure, then Preferences.
  2. Click on the + beside Java.
  3. Select syntax
  4. Check the box 'Enable Syntax Highlighting' and choose java.syn as the Sytnax Definition File

I Get A Popup When I Try To Save

If you get a popup that asks if you would like to register or continue evaluation, simply click on "Continue Evaluation". The trial period of Textpad will never run out.

Sample Code Does Not Compile

If your instructor has given you a code example which does not compile on your machine, you may have a different version of the JDK than they do. Please contact your instructor for instructions on getting the code to compile.

My java program compiles fine, but I get a "NoClassDefFound" error when I try to run it

Windows machines have what is called a "classpath" environment variable. When you try to run a Java program from your development environment (like TextPad), the classpath variable tells your system what directories / folders to look in for files (or classes) to run.

Usually, the classpath environment variable is set so that one of the places that will be searched is your "working folder / directory". Your working folder / directory is where you are saving all your files containing Java code.

Some software (Adobe products like Photoshop often seem to be the culprit) modify this environment variable so the working directory / folder is never actually checked for the classes you are trying to run. The end result is that when you try to run your program, you get a "NoClassDefFound" error.

This is an annoying problem. Fortunately, it is usually easy to fix.

The solution? Add a ";." (that's a semi-colon followed by a period) to the end of your classpath environment variable. The ";" separates the "." from the other directories / folders, and the "." specifies to look in the working directory.)

If you have the NoClassDefFoundError, take a look at your classpath environment variable (if you don't have one, then you likely don't have the problem described here) and see if that period is there. If not, follow the steps for the appropriate version of Windows.

Note: Be careful; making a mistake with your system variables can disable your entire machine.

Changing your classpath in Windows Vista:

  1. Click on START (lower left)
  2. Click on "Control Panel".
  3. Select "Classic View".
  4. Double-click on the "System" icon.
  5. Click on the "Advanced system settings" link.
  6. User Account Control may ask you for permission to continue. Select "Continue".
  7. Click on the "Environment Variables" button (near bottom).
  8. Highlight CLASSPATH and click the "edit" button.
  9. Add a semi-colon and a period (";.") to the END of the existing CLASSPATH. Alternatively, you can add a ".;" to the BEGINNING of the existing CLASSPATH.
  10. Exit the control panel. If the class problem persists, restart your computer.


Changing your classpath in Windows NT, 2000 and XP

  1. Click on START (lower left).
  2. Click on "Control Panel" (You may find the Control Panel directly off the start menu, or you might have to click on "Settings")
  3. Double-click on the "System" icon.
  4. Click on the "Advanced" tab.
  5. Click on the "Environment Variables" button (near bottom).
  6. Highlight "CLASSPATH and click the "edit" button.
  7. Add a semi-colon and a period (";.") to the END of the existing CLASSPATH. Alternatively, you can add a ".;" to the BEGINNING of the existing CLASSPATH.
  8. Exit the control panel. If the class problem persists, restart your computer.


Windows 98

  1. Click on START.
  2. Select RUN.
  3. Type in sysedit, then click OK.
  4. The system editor starts up with several windows showing. Go to the window that is displaying AUTOEXEC.BAT.
  5. Look for the CLASSPATH
  6. Edit the CLASSPATH statement by Adding a semi-colon and a period (;.) to the END of the existing CLASSPATH
  7. Close the AUTOEXEC.BAT window. If the class problem persists, restart your computer.
Previous Page: Setting up your own computer Next Page: Setting up your own computer