Step 8: Running and Debugging


Are you ready to see the fruits of your labor? Ready for the payback for all that hard work? Well wait no more; it's time to start running things!

In this step, you'll run your program. Not only that, you'll set a breakpoint, start the program in debug mode, stop at the breakpoint, inspect and change a variable, and continue execution ”all the steps needed to debug your programs.

Step 8.1: Running your HelloWorld program

click to expand
Note  

Some toolbar buttons , such as the Run button, also have a small dropdown symbol to the right. This dropdown brings up a secondary menu of options. The primary button usually will rerun the most recently selected option.

q 8.1 (a) Select HelloWorld.java if it is not already selected.

q 8.1(b) From the main tool bar, select the Run tool's dropdown.

q 8.1(c) Select Run ...

click to expand
Figure 8.1: Using the Run tool's dropdown, select the Run .. option.

This brings up the "launch configuration" screen. There are several options here, but we will concentrate on the Java Application option. I hope to write an entire book someday on working with JUnit, but that's another issue for another day.

q 8.1(d) Select Java Application and click New.

click to expand
Figure 8.2: Use the configuration wizard to create a new Java Application configuration.

The next page of the wizard will come up. This is a very complicated page, because you can set all kinds of things. Note that several defaults are already set, such as the Project name (Hello) and the Main class to run (HelloWorld). As long as you don't need to pass parameters or set runtime JVM characteristics, these defaults are often good enough.

Note  

There are times when you need to set certain runtime characteristics. We will see this when we use the SWT (Standard Widget Toolkit) classes in Step 9. But for these first examples, and in fact for many programming situations, the defaults are acceptable.

q 8.1(e) Leave the defaults as they are and press Run.

click to expand
Figure 8.3: Leave the defaults (Project = Hello and Main class = HelloWorld) and press Run.

And here are your results! Since this very simple program does nothing more than print to the standard output, the results show up in the console window. The console window magically pops up on top of the Tasks view, and shows you the results of your programming.

click to expand
Figure 8.4: The results of your application show up in the console window.



Eclipse
Eclipse: Step by Step (Step-by-Step series)
ISBN: 1583470441
EAN: 2147483647
Year: 2003
Pages: 90
Authors: Joe Pluta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net