Java Reference
In-Depth Information
R UN WITH E CLIPSE
Now it is time to execute your project with Eclipse. Choose the Run menu choice
at the top of the Eclipse screen. Then choose the first item on that menu, which is
Run. If Eclipse should ask you what type of project you have, select Java Applica-
tion. Eclipse will now execute the HelloWorld class.
At the bottom of the Eclipse screen, in the console window, you should see the
last part of the output from the Chapter 8 exercises. Use the scroll bar for that win-
dow to see the beginning of the output.
D EBUG WITH E CLIPSE
Next, you will use the Eclipse debugger. Double-click on the HelloWorld Java
source file from the Package Explorer. It will open up in the edit window. Then
click on the line that says System.out.println("Hello World!"); .
Move your cursor to the left-most section of the edit window. There should be
a blue bar on the side of that window. Click the right mouse button, and select the
Toggle Breakpoint option. A small blue ball should appear on the line, indicating a
breakpoint has been set for that line, as shown in Figure 17.7.
Choose the Run menu choice at the top of the Eclipse screen. Then choose the
second item on that menu, Debug. Eclispe will ask you to confirm that you want to
switch to the debug perspective. Choose Yes. Eclipse will now execute the Hello-
World class in debug mode.
Eclipse has many features in debug mode. The most common feature, and the
one you will use first, allows you to watch as you step through your program. At
this point, Eclipse has started the HelloWorld program and is stopped at the line
with the breakpoint. Try pressing the F6 button on your keyboard several times,
until you see the second statement with System.out.println . Notice how Eclipse
steps through the Java code. After the println statement is executed, notice how the
console window at the bottom is updated with the output from println .
Eclipse lets you easily see the current value of objects. Position your mouse over
the tempMsg variable. Notice how Eclipse shows you the contents of tempMsg .
The most common actions in debug mode are available in the Run menu
choice at the top of the Eclipse screen. Select that menu to see the actions available.
Choose the Resume option to let the program continue to completion.
 
Search WWH ::




Custom Search