Using C or C++ Project Launchers

See Also 

You can create launchers so you can easily run your project from the project context menu with different arguments, for example, or launch it from a script. Normally when you run your application from the IDE, the executable specified in the project properties as the Run command is executed. If you create launchers, you can specify multiple commands to run. Right-click the project and select Run As > launcher-name to run them.

You can use the same launchers for debugging by right-clicking the project and selecting Debug As > launcher-name.

To create a launcher:

  1. Open the project and go to the Files window (Ctrl-2).
  2. Open the folder nbproject/private and double-click the file launcher.properties to open it in the Source Editor.
  3. Edit the file to specify commands to run and display names to show in the IDE for running those commands. See the comments in the launcher.properties file that explain the macros you can use with the launchers.
  4. Save the file and go back to the Projects window.
  5. Right-click the project and select Run As to run the project using the launchers you specified.

Launchers Example

For the IDE's C/C++ sample application called Arguments, you could add the following to your launcher.properties file:

launcher1.runCommand="${OUTPUT_PATH}" "arg 1" "arg 2" "arg 3" "arg 4"
launcher1.displayName=Four Args

launcher2.runCommand=../dist/Debug/OracleSolarisStudio-Solaris-x86/arguments_1 "arg 1"
launcher2.displayName=One Arg

launcher3.runCommand=/bin/sh runMyProgram.sh

With this launcher.properties file, you would then be able to run the project using Run As > Four Args and Run As > One Arg or Run As > /bin/sh runMyProgram.sh.

The file runMyProgram.sh might be a script that sets environment variables for example, or does anything you want.

If you want to debug your application using a launcher that runs a script, you must also specify the option symbolFiles for that launcher so the debugger can debug the application instead of the shell used to run the script. For the launcher3 example above, this option could be added as follows:

launcher3.runCommand=/bin/sh runMyProgram.sh
launcher3.symbolFiles=${LINKER_OUTPUT}
See also
About C and C++ Projects

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.