handout #2

CSE 373

Installing Java for Windows

adapted from Stuart Reges's writeup for cse14x

For this course we will be using a combination of two software products: the Java tools from Sun Microsystems and a simple editor called TextPad.  The Java tools are known as the Java SDK (Software Development Kit), which is distributed freely by Sun Microsystems.  It includes a Java compiler and a Java runtime system.  TextPad is a shareware text editor.  The Computer Science and Engineering Department has purchased a site license for the use of TextPad to support CS instruction.  Both of these have already been installed on the machines in the Math Sciences lab.

Getting the Java SDK and TextPad on a Windows Machine

We will be using version 1.5 of the SDK. If you are using 1.4.2 from a previous quarter, you will be able to do most everything, but not generics. I won't give you anything with generics on the homework, but the textbook does use them. TextPad seems to work fine with Java 1.5, though I have not tested all the features extensively with generics. You can get a copy of the SDK at this url:

http://java.sun.com/j2se/1.5.0/download.html

There are several versions available on this page.  Be sure to follow the link that is labeled JDK 5.0 (you don't want Enterprise or netBeans).”  Install the SDK before you install TextPad.  You can get TextPad from:

http://www.textpad.com/download/index.html

Configuring TextPad

TextPad should automatically configure itself for use with the SDK, but there are a few settings you might want to choose.  Go to the “Configure” menu and select “Preferences.”

1.      If you want to see line numbers in the editor (because the Java compiler gives line numbers when it reports errors), select “View” and “Line numbers.”

2.      If you want Java files to be automatically opened by TextPad, select “Associated Files.”  Under “New extension” select “.java”.  Then click on “Add”.

3.      If you want TextPad to use Java files by default when bringing up a file dialog, select “File Name Filters.”  You will see a list of filters including “.java”.  Select this filter.  Then click on “Move up” until it is at the top of the list.

For any of these options to take effect, you will have to select “apply”.

Troubleshooting

  1. If you are having trouble installing, you can uninstall either or both programs and start fresh.
  2. Be sure to install Java before TextPad.
  3. If you go into TextPad and find that the Java tools are not on the Tools menu, you should first make sure that Java has actually been installed on the machine.  If it has, then you should be able to go to the Configure menu, select Preferences, select Tools and under the Add menu you should find the option “JDK Tools” or "Java SDK Commands"
  4. If you get this error message:

Exception in thread "main" java.lang.NoClassDefFoundError

Make sure that you have successfully compiled the program inside of TextPad (it should beep when you give the command “Compile Java”).  If the program compiles properly and you still get this error, then you probably have a setting for an environment variable called “classpath”.  You can verify this by going to Programs/Accessories/Command Prompt and giving the command “set c”.  This will show you all of your variables that begin with the letter “c”.  If you see a setting for classpath, then that’s your problem.  To fix it go to the "my computer" icon, right click and select properties, select the "advanced" tab, click on the "environment variables" button and find and delete the setting for classpath.

  1. If all else fails, you might need to clean up your registry.  Uninstall both programs.  Then run a program to clean up your registry.  For example, you might go to download.com and download a program like RegistryMechanic.  After you’ve run this program, restart your computer and run the installers again.