Working with Run launch configurations for Java programs

About this task

Run launch configurations allow you to specify and save the information required to run your application. You can reuse them for subsequent run actions. You can also create multiple launch configurations for the same application. The advantage of creating more than one launch configuration for the same application is that you can set different arguments for the program in the launch configurations window.

You can use the Run Launch Configurations window to create, remove, edit and duplicate launch configurations.

To open the Run Launch Configurations window:
  • From the workbench menu, select Run > Run.... Or, select Run... from the down arrow next to the Run push button .
To create a new run launch configuration:
  1. Select the Host Java Application Run configuration type, right-click it, and select New. The launch configuration tabs and entry fields will display on the right-hand side of the Run Launch Configurations window.
  2. Enter a name for your new configuration.
  3. In the Main tab, specify the connection you want to use for this configuration, or select one from the drop-down list. Or, click New to define a new connection.
  4. Check Has associated Java project if you want the launch configuration associated with a specific Java™ project in your workspace. Use the Browse button to specify the project.
  5. Specify the main class to run in the Main class field. Browse to your main class if this field is not automatically filled in.
  6. Specify the remote working directory where you want your program to run.
  7. Click the Arguments tab. Enter any necessary program arguments or Virtual Machine (VM) arguments and click Apply.
  8. Click the Classpath tab. Click Add to specify any new classpaths. Check Include working directory to class path if you want to add the remote working path to the class path automatically. Click Apply.
  9. Click the Environment tab. Click New to add environment variables if they are necessary.
  10. Click the Common tab to define additional properties for the configuration:
    • Select whether you want this configuration to be local to your workbench instance, or shared with your team.
    • Select one of the toolbar buttons check boxes, where you want the configuration to display as a favorite (a bookmarked shortcut).
  11. Click Apply to save the configuration. Click Run if you want to run the application right away.

Duplicating launch configurations

You can also create new launch configurations by copying existing launch configurations:
  • In the Run Launch Configurations window, right-click the launch configuration that you want to copy. You might need to expand the launch configuration type node to find the launch configuration you want to copy.
  • Select Duplicate from the pop-up menu.
  • The duplicate launch configuration appears beneath the original launch configuration (with (<number>) appended to the launch configuration name). The duplicate's settings are the same as the original launch configuration, and they appear on the right-hand side of the Run Launch Configurations window. Alter the settings as desired for your new launch configuration.
  • If all information mandatory to the launch configuration has been provided, the Run and Apply push buttons will be enabled and the new launch configuration will be saved.
You can also use the pop-up menu to remove existing configurations or create new ones.

Run with an existing launch configuration via the launch history

The launch history is a list of the most recent run launches. You can select an entry from the launch history to run it. In the workbench, the launch history appears when you select the down arrow next to the Run push button in the workbench toolbar or when you choose Run > Run History from the workbench menu.

You can modify the launch history in the workbench preferences. From the workbench menu, click Window > Preferences. In the Preferences window, select Run/Debug > Launching. In this page, you can set the maximum number of launch configurations that will appear in the launch history.

Relaunching

To run the launch configuration that was last used, do one of the following:
  • Select Run > Run Last Launched from the workbench menu.
  • In the workbench toolbar, click the Run push button .
  • Press Ctrl+F11.

Feedback