Run a program

Follow the steps below to run a sample Ballerina program in VS Code.

Use the code view

Follow the steps below to use the code view to run a Ballerina program.

Note: Skip the steps 1-3 if you already have a Ballerina code.

  1. Click View in the menu bar of the editor, and click Command Palette.

    Tip: Alternatively, use the shortcut methods ⌘ + ↑ + P on macOS and Ctrl + Shift + P on Windows and Linux.

  2. In the search bar, type Show Examples, and click Ballerina: Show Examples.

  3. Select the Hello World Main example.

  4. Run the program using one of the options below.

    • Option 1

      Click on the Run CodeLens on the editor.

    • Option 2

      Click Run on the title bar of the editor.

Use the diagram view

Follow the steps below to use the code view to run a Ballerina program.

  1. View the diagram using one of the options below.

    • Option 1

      Click Show Diagram on the title bar of the editor to view the graphical representation of the program.

    • Option 2

      Click the Ballerina icon in the VS Code side menu to open the diagram explorer tree.

  2. Run the program using one of the options below.

    • Option 1

      Click Run in the diagram options menu.

    • Option 2

      Click Run on the title bar of the editor.

The integrated terminal will open automatically and run the program.

Tip: Click the Debug CodeLens to debug the Ballerina program you ran. For more information, see Debug the code.