The page includes links to the software tools for downloading.
j2sdk1_3_0-win.exe
,
which you should save in some folder on your disk. I use
C:\Download
for this sort of thing because it is
compatible with WinZip's "Internet Extension"
software. (See the section on WinZip later
on this page for more information about this). Run this file (double
click on it from Explorer, or type its name in the box that comes up if
you click on Start->Run...), then follow the instructions that come
up for picking where to install the software. The default is
C:\JDK1.3
but you can put it someplace else if you prefer.
You will get a directory tree that looks like the following:
JDK1.3 bin demo include jre libNow you need to install the documentation, which will download as a file named
j2sdk1_3_0-doc.zip
. (Again, you should save it in
your Download
directory.) You need to unzip this
file and then extract the documentation files that are in it. To
do this, you need a tool such as WinZip. If you don't have this
program (or something equivalent) installed on your computer, you have
to download and install it before installing the Java
documentation. How to get that is described [ later in
this web page ].
When you run WinZip on j2sdk1_3_0-doc.zip
and click on the
"Extract" button, you will be asked where to extract the
files. The proper place is one directory (folder) above your
JDK1.3 folder. So, if you installed the software in the standard place
(C:\JDK1.3
), you would tell WinZip to extract the
documentation files to C:\
. The result will be a new
directory under JDK1.3
, which will be named
docs
. So, your directory tree will now look like this:
JDK1.3 bin demo docs include jre libYou have to get this directory tree set up right in order to be able to use the documentation. To check this out, use your web browser to open
JDK1.3\docs\index.html
(In Netscape Navagator use
the menus File->Open Page/Choose File...; In Internet
Explorer, use the menus File->Open/Browse...). Or you can
just type C:\jdk1.3\docs\index.html
as your web
address.Scroll down the page and click on the link to "Java 2 Platform API Specification" and save that page as a bookmark so you can get back to it easily. It may take some time for you to get comfortable with navigating through the API documentation, but it will be invaluable once you get it, and it's a lot cheaper than the big reference books from Addison-Wesley! (But it doesn't have all the great explanations and sample code found in the A-W books either.)
Use your browser's Back button to get to
JDK1.3\docs\index.html
again, and scroll down to the link
to "Tool Documentation" under the SDK Tool
Documentation heading. This link will get you to documentation on
the javac, java, appletviewer, and javadoc commands,
among others.
There is also a copy of the JDK documentation set up for browsing from the computer in my office. You can use [ this link ] to access it.
To run a JDK command, you should be able to type the name of the
command at the command line. Try typing just "javac" at the
C:>
prompt. If the command runs (and prints a message
that starts "Usage: ...
") you're all set. But if
you get a "command not found message" you need either to type
the full pathname of the command (such as
"C:\JDK1.3\bin\javac") or add the pathname of the JDK's
bin directory to your PATH environment variable. Your
PATH
environment variable should have been set up properly
(normally by putting a command in your autoexec.bat
file)
when you installed the JDK. You could do this yourself, if necessary,
by typing the following command:
set PATH=C:\JDK1.3\bin;%PATH%This command prepends the pathname to your JDK bin directory to the current setting of your PATH environment variable. You could type this command by hand every time you start a new DOS prompt window, but life is a lot easier if you put this command at the end of your autoexec.bat file so it is automatically run each time you start your computer.
You may have heard about an environment variable named
CLASSPATH
that needs to be set properly in order to use
the JDK commands, but in fact it does not need to be set, in
general. If it is set, it should have a value that looks like
".;C:\JDK1.3\bin
". You can check this by typing
"set CLASSPATH" at the command line. If CLASSPATH has a
different value and you have trouble running the JDK commands,
you can get rid of it by typing "set CLASSPATH=".
(Note that the first set command has no equal sign, and shows
the value of the variable, whereas the second one has an equal sign at
the end, and assigns an empty value to CLASSPATH, effectively
"unsetting" it. The current version of the JDK does not
require you to have a value for CLASSPATH.
You may already have an Integrate Development Environment (IDE) for
Java installed on your computer (VisualAge, Cafe, JBuilder, Visual
Studio, ...), in which case there may be a value set for
CLASSPATH
. As long as the command-line tools work
correctly, there is no need to worry about
CLASSPATH
.
Text Editors
<tab>
characters, and you can set the tab
settings to a "reasonable" value. (I use a tab width of 2
characters, but 3 and even 4 are also reasonable values. If you use
anything larger, using <tab>
to indent your code
will make it go too far to the right, leading to wrapped lines that
are impossible to read.)
It is very important to substitute spaces for<tab>
characters in your programs because different software treats<tab>
characters differently. For example, if you have your tab width set to 2 when you edit your program, and somebody prints or views it with software that assumes a default value of 8 (which is typical), they will find your code impossibly difficult to read because nothing will line up right.
Control-B
), the editor will show you the matching
brace character in the file, either by highlighting the characters
in between the matching pair of braces or by jumping the cursor to
the matching brace. Pair matching also works for parentheses and
square brackets. Good indenting habits can reduce the need for this
feature, but we all need it once in a while, and not having it can
be a real bother.
Note: PFE is no longer being developed or maintained by its author, but the final version is still available, and it's free.[ Download from Lancaster University (United Kingdom). ]
The price is right for this one, and the set of available features is very good. However, it does not support syntax highlighting, which shows program keywords, variable names, comments, and constants in different colors. Syntax highlighting is nice, but what do you want for free? You can set this editor up to work very well for you.
Installation is not automatic. The program will download as a .zip
file, which you will probably save in your \Download
directory. Extract the contents to any directory you wish using WinZip.
(See [ WinZip ] if you don't already have Winzip
or something equivalent on your computer.) I used C:\Program
Files\PFE
as the directory to extract the files to, for example.
(You have to create the directory before doing the extraction, but
Winzip has a button to create it for you in the Extract
dialog.)
You might want to drag the icon for the program to your desktop, add the program to your Start menu, and/or create a keyboard shortcut for the program to make it easy to get at. To do this, use Windows Explorer to drag the icon for the program to your Desktop and/or Start Menu folder, which will create a shortcut icon. If you right-click on the shortcut, you will get a menu with Properties listed at the bottom; click on that, select the Shortcut tab in the dialog box that comes up, and type in the letter you want to use to start the program in the "Shortcut Key" box.
You should make a directory for doing your projects in this course
(and you will probably want a subdirectory for each project). You
can use Windows Explorer to create your project directory by
selecting the parent directory (perhaps C:\
) and using
File->New->Folder to create the new directory. It will be
highlighted so you can easily rename it (perhaps to "CS-101
Projects
").
Use the Options->Default Modes menus to bring up the Default
Modes dialog box. Click on Edit Mode Groups, then click on New...,
and enter something meaningful, like Java Source Code in the
Mode Group Name box, and *.java
in the Filename
Patterns box. Click OK twice to get back to the Default Modes
dialog. Click on Edit Modes... in the lower left corner of this
dialog. Select Mody type "input" and check the
"Auto-indent new lines" and "Strip trailing
spaces..." boxes. Select the "Language Awareness"
Mode type and choose "C". Go down to the "Text
Formatting" Mode type, and click the "Tab with space
characters" radio button, and change the Tab stop box from 8
to 2 (or 3 or 4, as you prefer). Check the Enabled box in the Text
wrapping section, leaving the column number at 72 so that you will
know when you type lines that are too wide. (You might not like the
text wrapping option, in which case, leave the box unchecked; just
don't hand in any code with any lines wider than 72 characters for
this course.) Click OK to get out of the Edit Default Modes dialog
box, and click Close in the Default Modes dialog box. Wait!
Before you close the Default Modes dialog box, you might want to
edit the default modes for windows showing templates, windows
showing macros, and windows created by file new in the same ways as
for Java Source Files.
Use the Options->Preferences->Editing Files menus
to select other options you might want to set. In particular, you
should turn on the Use Smart Tabbing checkbox here. With this option
on, if you select a block of text and press the <tab>
(or Shift-<tab>
) key, the code will be indented
(or unindented) one tab stop.
When you are editing your code, you can put the cursor to the left
of a brace, square bracket, or parentheses, and type
<Control-B>
; the editor will move the cursor to
the matching symbol in the file, if there is one. Press
<Control-B>
again to jump back to where you
started.
You might want to look into the editor's template and macro features. You can set up a templates containing boilerplate text, like at the comments at the beginning of a class or method, with a couple of clicks of the mouse, and you can use the macro feature to capture a sequence of keystrokes to be played back at a later point. Also, you can bind any editing command or macro to hot keys using the Options->Key Mapping... menus.
Finally, you will probably want to use the Execute menu to
compile your programs from within the editor. With a .java file in
an editing window, click on the Execute menu button and
select DOS Command to Window... (or press
<F11>
) to bring up a dialog box. The command you
want to execute is "javac %f
", which
will compile the file you are editing. If that doesn't work, you
may need to give the full pathname to the java compiler,
"C:\JDK1.3\bin\javac %f
" for example.
Once you have done this one time, the editor will remember the
command the next time you press <F11>
.
This is an excellent shareware programmer's editor. It may not have quite as many customization features as PFE (it has macros and templates, but they aren't quite as rich as PFE's), but it does do syntax highlighting (which a lot of people like), has some other features that PFE is missing, and needs very little work to get it set up "right". Just unzip the file you download, and run Uedit32i.exe to install it. The one thing you want to make sure you do is to go to the Advanced menu, select Configuration, go to the Edit tab, and be sure you have selected the "Use spaces in place of Tabs" checkbox.
To compile Java programs from within UltraEdit, go to the Advanced menu and click on the "Tool Configuration ..." menu item. For the command line, type javac -deprecation "%f". Leave the "Working Directory" field empty, type "Javac" for the Menu Item Name (or whatever you want to appear on the Advanced menu), turn on "Output to List Box" and "Capture Output." Be sure to click on Insert before you click on OK, or your settings will get lost. Now, when you are editing a Java source file you can compile it by clicking on Advanced->Javac or by typing Ctrl-Shift-0. Any syntax errors will show up in a panel at the bottom of the editor window. Click on an error message to take you to the correspoinding line in the source file.
Some of the other features I like about UltraEdit are its "column mode" which lets you insert, move, and delete columns of text the way you normally work with lines, and its "hexadecimal mode" which lets you look at and modify the binary codes for the characters (or anything else) in your file. It also handles plain text files a bit better than PFE, and it lets you look at the spaces and tabs (there better not be any of the latter!) in you file. It also lets you put a column indicator on the screen so you can see when you are getting close to your righthand margin. Finally, it comes with a utility (and instructions) that lets you replace Windows' abominable Notepad editor with UltraEdit in a clean way. All in all, it's a full-featured product for a very reasonable price. You can try it free for a month, then you have to send the author $30. After a year, you have to pay another $15 if you want to download updated versions.
You can evaluate this editor free for 45 days. It's got a lot of nifty features, but the cost puts it beyond what is reasonable to spend for this course, I think.
C:\Download
to hold files that you download. Run the program by double-clicking on
it to install it. I recommend that you select "classic" and
"express installation" when asked.
The "WinZip Internet Extension" is a separate program that you
can download and run, which will automatically start up WinZip when you
download a zip file from the Internet. The idea of creating a directory
named C:\Download
, by the way, comes from the default
configuration this program likes to work with. You can just install it
and forget about it; it will do its thing when appropriate.
The WinZip utility can be used both to create zip files (also called archives) and to extract files from archives (also called unzipping the archives).
To create a zip file for submitting an assignment, follow these steps:
Project_1.zip
in the selected directory.
I do not recommend that you use an IDE for this course for two reasons. The first is that getting an IDE set up and mastering its use will take time and effort that will distract you from the content matter of the course. The second is that you are required to submit all code so that I can compile and test it using the JDK. If you develop the code using an IDE, you then have to extract the .java files from the IDE environment and test them using the JDK to make sure they still work. This extra work will, I think, more than offset any efficiency you get by using the IDE for development.
Having said that, I will say that I think the IBM IDE is particularly good, and they have made a copy of it available for students to use at no cost. If you are interested, see me about borrowing the CD.