Lecture Notes for Tuesday March 7, 2000


Exam 1 and 2 makeup


Too many to do individually. We will choose two days next week for the exam -- one evening (possibly Wed or Thur) and a Satuday time - we will finalize this on Thursday of this week

Return of papers


All papers and graded summaries were passed out. Mistakes were noted so midterm grades could be correctly submitted. If you were not in class and your midterm grade is wrong, it is too late to change it.

15-120 for the rest of the term


There will be no more printed class notes. These notes will be posted and available from the calendar web page. These will be generated from the notepad stuff that Jim types in class. They will not summarize the lecture. This version is very complete because Jim lost the notes he typed in class. The next ones will be much shorter.
If you miss the lecture, you will have to get the notes from someone in class. We will not do mini-lectures in office hours.
You do need to read the book. It is much better than any lecture notes could be.
You also need to come to class.

Writing a Java program


First you must be sure your computer can run Java. Here are the steps.
1. Start a command prompt or dos prompt window.
2. Change the focus of the dos prompt window to be C:\Temp
3. At the prompt type the following and press return: javac
4. If you see an error message similar to this:
The name specified is not recognized as an internal or external command, operable program or batch file.
your machine is set to run Java.
If you do see this message, you need to see if Java is on your machine. To do this use the find utility program available from the start menu and search for the file: jdk1.2.2 or the file jdk 1.2.1 If the find utility program finds it, follow the next step. If it does not find it, you cannot run Java on your computer.
5. Since you are reading this step, you must have Java on your computer. Do not close the find file utility program just yet. The problem is that the computer cannot find the executable java stuff to compile and run your java programs. The following syntax can be used to temporarily reset the computer to be able to find this important java stuff.
In the command prompt window type the following two lines at the prompts
set path=%path%;C:\??????\jdk1.2.2\bin
set classpath=.;
The ?????? are replaced by the location of the folder as shown in the find file utility. This can vary from place to place.
Jim just checked out 5207 Wean cluster and you have to do this in that cluster. In 5207 Wean the ?????? is replaced with C:\

Using doskey


The history of every command you type into the dos or command prompt window can be accessed by the up and down arrow keys on the right side of the keyboard. This is referred to as the "doskey" (pronounced dos-key) program. Try it and if it works, you can use it to save typing. If it does not work you can start it by typing doskey and pressing return.

Compiling and running the Java program


First you type the program using Codewarrior (preferred) or another word processing application. Codewarrior is preferred because it saves as text automatically and has a "go-to line #" feature that makes finding errors fairly easy. If you use Word, be sure to save as text. If you use notepad, you will have to count your own line numbers...
Once you have entered the program, you MUST
-- save the file with the same name as the class that is in the file and
-- use the extension .java
We strongly suggest you use as the class name the lab number. So for Lab 7 instead of typing the class name, Colors, you should use Lab7 (no space) and you should save the name of the file as Lab7.java. By convention, class names in Java are capitalized so it should be Lab7 and not lab7.
Now you must compile the file to find the errors or create the .class file. To compile your Lab7.java, return to the command prompt or dos prompt window and do the following
1. Type dir and press return. You must see your Lab7.java file or this will not work. If you do not see it, you saved it to the wrong place. Return to your editing program and resave the file to the correct place.
2. Type the following and press return: javac Lab7.java
If there are any errors, they will be listed starting with the line number. They will be a bit (only a bit) better than the robot simulator.
If there are no errors you will get the prompt back - no congratulations or pats on the back - just the prompt.
3. Type dir and press return. You should see a new file called Lab7.class in the list. This in a binary file that contains the encoded program that the computer can execute.
4. Once the errors are eliminated, you must now create a .html file similar to the one on page 17. The line that reads, code = "Hello.class" must be replaced with the line, code = "Lab7.class" being very careful to keep the case of the letters the same and the quotation marks in place.
Save the file with the name Lab7.html>BR> 5. Return to the dos prompt window and type the following at the prompt: appletviewer Lab7.html
You will a dialog box - type accept - and then you will see your applet only.
To see the applet in the browser, you can return to the windows interface and double click the Lab7.html file. This will open the browser and run your applet.

Handing in your Java Labs


1 -- You will still create a folder named with your last name, first if needed, and section. In that folder you must put your .java and .html file. Do not turn in the .class file - it is too big.
2 -- You must link this lab from your home page so Jim can run the applet. You can create a separate page of java links or link them individually from your home page - the choice is yours.
You need to ftp your .html and .class files to your www folder. DO NOT ftp your .java file since the world can read your www folder and thus copy your .java file - this can lead to cheating problems... If you name your programs by their lab numbers, you will never have a file name problem. This first lab would require you to ftp Lab7.html and Lab7.class to the www folder. The next lab would have files Lab8.html and Lab8.class.
No credit is received until your applet can be executed from your web page. That is part of each lab requirement and is also due at 8:00 a.m.
You must republish your web page when you add your applets.