Running your programs

In this section, you will learn more about running Java programs in the workbench.

1.

In the Package Explorer view, find junit.textui.TestRunner.java and double-click it to open it in an editor.

2.

In the Outline view, notice that the TestRunner class has an icon which indicates that this class defines a main method.

Outline view with selected TestRunner class

3.

Using the drop-down Run button in the toolbar, select Java Application from the cascading Run As menu. This will launch the class in the active editor, or the selected class in the Navigator, as a local Java application.

Run drop down menu

4.

Notice that the program has run and the following message appears in the Console view telling you that the program needs an execution argument.

Console with error message: Usage: TestRunner [-wait] testCaseName, where name is the name of the TestCase class

5.

Using the drop-down Run menu in the toolbar, select Run....

Run menu of the toolbar

6.

The Launch Configurations dialog opens, and the TestRunner launch configuration is selected. When you ran the program using the Java Application shortcut, a launch configuration was automatically created with default settings to launch the selected class.

Launch configuration dialog showing the Main tab

7.

Select the Arguments tab and type junit.samples.VectorTest in the Program arguments area.

Arguments tab of the launch configuration dialog

8.

Click Run. This time the program runs correctly, indicating the number of tests that were run.

Console showing program output

9.

Switch to the Debug perspective. In the Debug view, notice that a launch was registered each time the program was run.

Debug view showing two terminated run launches

Note: You can relaunch any of these processes by selecting Relaunch from its context menu.

10.

Select the drop-down menu from the Run button in the workbench toolbar. This list contains the previously launched configurations. Configurations can be relaunched by selecting them in this history list as well.

Run drop down menu from the workbench toolbar

11.

From the context menu in the Debug view (or the equivalent toolbar button), select Remove All Terminated to clear the view of terminated launches.

Debug view showing context menu