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.
- From the workbench menu, select Run > Run.... Or, select Run...
from the down arrow next to the Run push button
.
- 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.
- Enter a name for your new configuration.
- 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.
- 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.
- Specify the main class to run in the Main class field. Browse to your main class if this field is not automatically filled in.
- Specify the remote working directory where you want your program to run.
- Click the Arguments tab. Enter any necessary program arguments or Virtual Machine (VM) arguments and click Apply.
- 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.
- Click the Environment tab. Click New to add environment variables if they are necessary.
- 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).
- Click Apply to save the configuration. Click Run if you want to run the application right away.
Duplicating 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.
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
- Select Run > Run Last Launched from the workbench menu.
- In the workbench toolbar, click the Run push button
. - Press Ctrl+F11.