Ballerina is a new open source JVM based language specially designed for integration purposes by WSO2 the world's #1 open source integration vendor. In this article, you will see how to manually install Ballerina on Linux systems. Visit the official website and download the installer for your system. There is an installer for Windows, Mac, Debian-based Linux and Fedora-based Linux. I prefer to install Ballerina manually because it is universal for all Linux operating systems out there.
Step 1:
Ballerina is a JVM based language like Kotlin and Scala. Therefore, you must have Oracle Java Development Kit 1.8 installed in your system. If you don't have Oracle JDK 1.8 installed in your system, follow this article: Install Oracle JDK 8 on Linux.
Step 2:
Download the latest ballerina-<version>.zip file from the official website. In this article, I am using ballerina-0.990.2.zip.
Step 3:
Open a terminal and change the directory to /usr/local
cd /usr/local
Step 4:
Extract the zip file into the /usr/local folder. In the following command, I assume that you have the ballerina-0.990.2.zip file in the Downloads folder.
sudo unzip ~/Downloads/ballerina-0.990.2.zip
Step 5 (Optional):
Rename the ballerina-0.990.2 folder to ballerina. I prefer to do so because it will permit me to upgrade the language without modifying the
PATH
variable every time.sudo mv ballerina-0.990.2 ballerina
Ballerina strictly requires Java Development Kit 1.8. If you have more than one JDKs installed in your system and the
JAVA_HOME
variable points to a different version, Ballerina may not run in your system. To overcome this problem, we can hard-code the JAVA_HOME
variable in the ballerina executable file. To do so, follow these steps:6.1:
Open /usr/local/ballerina/bin/ballerina in nano
sudo nano /usr/local/ballerina/bin/ballerina
6.2
Scroll down the comments and find the line starting with
BASE_DIR=$PWD
. Just before that line, hard-code the JAVA_HOME
variable. In my case, JDK 1.8 is installed in /usr/lib/jvm/jdk1.8.0_181 so I modified the ballerina executable as shown below:...
# OS specific support. $var _must_ be set to either true or false.
#ulimit -n 100000
JAVA_HOME=/usr/lib/jvm/jdk1.8.0_181
BASE_DIR=$PWD
cygwin=false;
darwin=false;
...
Step 7:
Append
/usr/local/ballerina/bin
to the environment variable PATH
and set /usr/local/ballerina
as BALLERINA_HOME
. You can set them to the entire system by following these steps:7.1:
Open /etc/environment in nano
sudo nano /etc/environment
7.2:
Append
/usr/local/ballerina/bin
to the PATH
variable and add BALLERINA_HOME
as shown below:PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk-11/bin:/snap/bin:/usr/local/ballerina/bin"
JAVA_HOME="/usr/lib/jvm/jdk-11"
BALLERINA_HOME="/usr/local/ballerina"
Press Ctrl + O to save all changes and Ctrl + X to close nano.Step 8:
Restart the computer or enter the following command in the terminal to load the environment variables.
source /etc/environment
Step 9:
Enter the following command in the terminal to check the version of Ballerina. If it prints the version, congratulations! you have successfully installed Ballerina.
ballerina --version
If you face any problems in installing Ballerina, feel free to comment below. I will try my best to help you in fixing them.
EmoticonEmoticon