DEV Community

Shan Mahanama
Shan Mahanama

Posted on

Setting up Ballerina in IntelliJ IDEA

Ballerina is a new open source programming language with textual and graphical syntaxes. From this article, I am focusing on providing a step by step guide for setting up a Ballerina project in IntelliJ IDEA. If you want to learn more about Ballerina Language, you can refer this article.

Installing Ballerina plugin

So the first thing we need to do is installing Ballerina plugin to IntelliJ IDEA. But please note that you must have IDEA version 2016.3 or above to use the plugin. This plugin supports both IDEA Community and Ultimate versions.

Steps to install Ballerina plugin -
1) Go to File (Preferences in MacOS) -> Settings.
2) Select Plugins section and click on Browse repositories button.
3) Type “ballerina” in the search box. Ballerina plugin will be shown as below. Click on the Install button.
Browse Repositories
4) After installing the plugin successfully, you need to restart the IDEA.

Downloading Ballerina runtime

To use Ballerina plugin to it’s full potential, you need to add the Ballerina Runtime as a SDK to the IDEA.
You can download the runtime distribution from the BallerinaLang website. Download the runtime distribution and unzip the file.

Creating a new Ballerina project

1) Go to File -> New -> Project.
2) Select Ballerina project type and select Next.
Project Wizard
3) Now we have to setup a Ballerina SDK in the next window. Click on Configure button.
Project Wizard
4) Then select the unzipped runtime directory and select OK.
SDK Home selection
5) If you followed the steps correctly, the Ballerina runtime should be added as a SDK successfully. Now select Next.
Project Wizard
6) Now update the Project name and Project location and select Finish.
Project Wizard
7) Ballerina project will be created and opened like shown below.
Ballerina Project

Creating a new Ballerina file

1) Go to File -> New -> Ballerina File.
2) Enter a file name and select the Ballerina Main kind. Ballerina Main kind will create a new file with a main function. There are few other kinds as well.
New File
3) Now you will have a new Ballerina program file with a main function.
New File
4) Now you can use the run icon next to the main function to run the program. If you don’t add a Ballerina SDK, you wont be able to run Ballerina programs in the IDEA. That is why we configured a Ballerina SDK in the previous section.
Run File
Click on the run icon and select the run command.
Run File
5) You will see the output in the Run window.
Run Window

Congratulations, you have successfully configured Ballerina in IntelliJ IDEA and executed the Hello World program. Now you are ready for some serious action in Ballerina :)

So where to next?

You can refer Ballerina by Example to see various examples written in Ballerina. Also if you have questions, suggestions, etc, you can -

Top comments (0)