Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Java Development User Guide
Previous Page Home Next Page

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 the class defines a main method.

    Outline view with selected TestRunner class

  3. Right click on TestRunner.java in the Package Explorer and select Run As > Java Application. This will launch the selected class as a local Java application. The Run As context menu item is also available in other places, such as the Outline view.

    Run context menu

  4. Notice that the program has finished running and the following message appears in the Console view telling you that the program needs an execution argument.  Running class from the Package Explorer as a Java Application uses the default settings for launching the selected class and does not allow you to specify any arguments.

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

  5. To specify arguments, use the drop-down Run menu in the toolbar and select Run Configurations....

    Run menu of the toolbar

    You can also Ctrl+Click a configuration in the drop-down menu to start editing that configuration.
  6. This time, the Launch Configurations dialog opens with the TestRunner launch configuration selected. A launch configuration allows you to configure how a program is launched, including its arguments, classpath, and other options.  (A default launch configuration was created for you when you chose Run > Java Application).

    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 process for the last program launch was registered when the program was run.

    By default, the Debug view automatically removes any terminated launches when a new launch is created. This preference can be configured on the Goto the Launching preference page Run/Debug > Launching preference page

    Debug view showing two terminated run launches

    Note: You can relaunch a terminated process 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 programs. These programs can be relaunched by selecting them in the history list.

    Run drop down menu from the workbench toolbar

  11. By default the currently selected resource or active editor is launched when the run button is hit. If none of these is launchable the current project will be launched. You can configure this behaviour under Goto the Launching preference page Run/Debug > Launching .

    Debug view showing two terminated run launches

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

    Debug view showing context menu

Related tasks
Changing debugger launch options
Connecting to a remote VM with the Remote Java application launch configuration
Disconnecting from a VM
Launching a Java program
Running and debugging

Related reference
Debug view
Run menu actions
Run and debug toolbar actions


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire