For those who like to work on the Solaris machines in Sweet Hall, Eclipse is installed in our class directory. To use this installation, add /usr/class/cs108/bin to your path and type runeclipse. (Check out the Java on Unix page to see how to set your path).
If you prefer to work from your room, you can get Eclipse here. Eclipse is available for Windows, Mac OSX, Linux, and a variety of Unix platforms. You will also need the Java Development Kit (JDK) available here. We'll be using version 1.5 this quarter. Mac OS X machines have Java 1.4 built-in. For Java 1.5, Mac users need to be running Mac OS X 10.4 and then download the latest Java 1.5 from the apple site.
You will want to create a new project for each assignment in CS108. This will let you separate the files for each HW into different folders. Before you start, make sure you're using the Java 1.5 environment. Go to Window->Preferences. On the left pane, click Java->Editor->Installed JREs. Make sure that the 1.5 JRE is added and checked.
Then click Next. Now, give your project a name. Click "Create project from existing source" and add then add the directory in which your project lives. We want to use Java 5 (also known as Java 1.5), so you can either specifically select it, or set 5.0 to as the default. Also, click on "Use project folder as root for sources and class files."
Now, just click Finish and you're done creating the project! If it asks you to switch to the Java Perspective, say yes.
Another thing you want to do is make sure the project is using the correct JRE. Right click on your project in the Package Explorer on the left and click on Properties. Select Java Build Path and Choose the Libraries Tab. If the JRE is 1.5, you're fine.
If this isn't the case, you need to set a
different JRE for the project. Click on "JRE
System Library", and then click Edit. Select
Alternative JRE and select the JRE you want
from the drop down box.
Now if you want to stop debugging at any time, click Run->Terminate. (If you see a blue "all done" in the Console at the bottom, then you have finished running the program, and you won't be able to Terminate.
When you run the debugger, the program will now stop before executing the lines with breakpoints.
In the picture above, I placed a breakpoint on the line that says i++.
You can step through your program one instruction at a time. You can choose to step into methods or over them. This can be done from the Run menu, or by using the buttons on the Debug toolbar:
To set a breakpoint that triggers only when certain conditions are true, i.e. a conditional breakpoint, or set them to trigger only after being hit a certain number of times, right-click the blue dot/breakpoint and select Breakpoint Properties....