If you are using one of the Macs in 005 Sudikoff, skip to item 4.
The amount of disk space you will need to do this will vary according to your system. Once you are done installing the components, you can throw away the installers, which will recover a fair bit of space. You can always get the installers back off the file server later, if you need them.
Pay careful attention to the instructions. Follow them exactly. From here on, we'll assume that you have installed Eclipse correctly, and that you have configured Eclipse per the installation instructions to make look like mine.
This image is from Mac OS X. If you're running Windows, you'll see something equivalent. (Mac OS X uses slashes to separate folder names; Windows uses backslashes. Mac OS X uses triangles next to folders that you can expand; Windows uses plus-signs.)
Here, /Users/thc/ is my home folder on my Mac.
Click the "Finish" button.
"src" is short for "source," and it's where you will put programs in order to run them. We call the actual text of a computer program the "source code."
Click on the triangle (Mac) or plus-sign (Windows) next to "(default package)" and you'll see
You may remove Mystery.java from your Desktop, or wherever you saved it to, if you like.
Note that this causes a new tab, "Console," to appear near the bottom of the window. Click on "Console" and you will find a question. Click to position the cursor in the console tab to the right of the question, answer the question, and note what happens. You should see a new window come up with something in it. If you don't see that window, it's probably because your Eclipse is covering it; in that case, move the Eclipse window until you see the new window completely. Write down what you see in that new window. You do not have to say much. We want to know that you have succeeded.
First, click on "src" to highlight it. Then go to the "File" menu and drag down to "New," then choose "File" from the popup menu that appears. You need to select a parent folder. Because you have already selected the default package in src under cs5proj, you will see that cs5proj/src has already been chosen as a parent folder; that's just what you want:
You then need to type in the name of your new file next to where it says, "File name:." Let's assume that you choose "Logo.java" as the file name. The ".java" is essential, because the name of the file has to be the same as the name of the class inside it. Then click "Finish."
The middle of the window will be a tab labeled with the name of your program ("Logo.java" in our example.) Type in the logo program, with a logo of your choosing. (See the explanation below under Exercises.) You can model it after the class examples. Note that Eclipse automatically indents your program as you type it, and does things like putting closing braces and parentheses when you type the opening ones. Also, if a line has an error in it, a red error mark will appear in the left margin in front of it.
You can have Eclipse help you even more by selecting File -> New -> Class instead of File -> New -> File. A screen will pop up. Type in the name and click the box next to "public static void main(String[] args)". When you type in the name, bear in mind that it's the name of a class, not the name of a file. For example, if you want your class to be named "Logo", then you should type "Logo" rather than "Logo.java." Don't worry; Eclipse will create the file Logo.java for you! If the name of the class is Logo, the window will look as follows just before you click "Finish."
If you do this some comments (in a special form called JavaDoc), a class declaration, and a declaration of the main method will be provided, and you must fill in the bodies.
Your program may not run correctly the first time. If that's the case, then you have had an early initiation into the world of programming. Errors are common in programming. We all make them. Even me. Fixing mistakes is a significant part of developing programs. If you have an error, check the syntax of your program carefully. Are the semicolons, curly braces, parentheses, and quotation marks correctly placed? Did you misspell something?
If you need help, you can contact a Section Leader, a TA, or me to get help. Remember that if you blitz cs5help@cs.dartmouth.edu, the first available person will respond. If you ask for help by Blitz, please remember to enclose a copy of your program: without it, we cannot tell you what's wrong with it. Remember that when you Blitz a program it must be a Blitzmail enclosure. Please do not copy and paste your program into the message; we will have a hard time running it if you copy and paste, but it's easy for us to run it if you make it an enclosure. Your program is found in the src folder within the cs5proj folder within the folder that you selected as your workspace. (For example, on my Mac, it's in /Users/thc/Documents/workspace/cs5proj/src.)
When your program execution completes, you'll be left with the Console panel containing the output of your program. We have not yet found a way to print the Console panel. (You'd think that you could click in the Console panel and then choose "Print..." from the File menu, but the good people who wrote Eclipse disabled printing when the Console panel is active. Go figure.) So what you need to do is to copy the output and paste it into a word processor's window (Notepad on Windows or TextEdit on the Mac are easy ones to use, although Word will also work.) Make sure that you use a monospaced font in your word processor; otherwise, the logo won't print with the same spacing that you see on the screen. (A monospaced font is one in which all characters have the same width, such as Courier.) Then print that window. Alternatively, you can take a screenshot and print that. (On Windows, use the PrntScrn button. On the Mac, you can take a shot of just the window you want by using the Grab utility.)
Remember that the schedule page tells you what reading to do before each lecture. We expect you to do the reading.
Read Chapter 1 and Sections 2.1-2.3 for Thursday. Yes, it's a lot of reading, but Chapter 1 doesn't have much detail.
The program should be very simple, essentially consisting of
just a few System.out.println() statements within
your main method. In this example, the third
statement might be
You will not turn in this short assignment electronically. In fact, you will not turn in any short assignments electronically. Short assignments are always turned in as hardcopy. It is only the lab assignments that you will turn in electronically (and on hardcopy as well).
Collect your printouts, and put them in an envelope that is at least 8.5 x 11 inches, and write your name on the outside of that envelope as well. We will not accept your assignment if it is not in an envelope. If you cannot afford an envelope, please see me or a TA, and we will get you one. Leave the envelope in the CS 5 HW HAND IN boxes in the lobby outside 008 Kemeny by the start of class on Friday. (Since you won't know which section you're in at that time, you can put them in any one of the CS 5 HW HAND IN boxes that has a Section Leader's name below it.) And have fun.
Please remember in all assignments that editing the output of the program before printing it is a violation of the Academic Honor Principle. Make sure that the output you turn in comes from the program that you turn in. If you make any change to the code, no matter how insignificant you think it might be, rerun your program to produce new output!!