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. Click Show Diagram on the title bar of the editor to view the graphical representation of the program.

  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.