Setting up Ballerina in IntelliJ IDEA

Shan Mahanama
Ballerina Swan Lake Tech Blog
4 min readNov 14, 2017

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 to this article.

Installing Ballerina plugin

So the first thing we need to do is installing the 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.
Settings window

3. Type “ballerina” in the search box. Ballerina plugin will be shown as below. Click on the Install button.

Browse Repositories window

4. After installing the plugin successfully, you need to restart the IDEA.

Downloading Ballerina runtime

To use Ballerina plugin to its full potential, you need to add the Ballerina Runtime as an 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.
New project wizard — Step 1

3. Now we have to set up a Ballerina SDK in the next window. Click on the Configure button.

New project wizard — Step 2

4. Then select the unzipped runtime directory and select OK.

SDK home directory selection window

5. If you followed the steps correctly, the Ballerina runtime should be added as an SDK successfully. Now select Next.

New project wizard with Ballerina SDK

6. Now update the Project name and Project location and select Finish.

New project wizard — Step 3

7. Ballerina project will be created and opened like shown below.

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 the main function. There are a few other kinds as well.

3. Now you will have a new Ballerina program file with the main function.

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 won't be able to run Ballerina programs in the IDEA. That is why we configured a Ballerina SDK in the previous section.

Click on the run icon and select the run command.

5. You will see the output in the 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 -

--

--