import ballerina/io;
public function main() {
    io:println("Hello, World!");
}

Hello World Main

Let’s print “Hello, World!” using a main function in Ballerina. A public function named main is considered an entry point to a Ballerina program.

import ballerina/io;
public function main() {
    io:println("Hello, World!");
}

The main function, which acts as the entry point.

# To run this sample, navigate to the directory that contains the
# `.bal` file and execute the `ballerina run` command.
$ ballerina run hello_world.bal
Hello, World!