This post shows how to run Ballerina On Command-Line without installing the Java Development Kit (JDK) in Windows 10 64-bit. Instead, we use a zip distribution of Java with only two environment variables. This distribution of Java is self-contained that we install anywhere on a local disk where we have permission to write. We download the zip file and extract it to a directory.
Set-up Java Without Installing
First, download an OpenJDK and extract it to some directory. Choose OpenJDK 8 (LTS), click the Other platforms button.
Then, scroll the page down until we see the JDK zip distribution for Windows 64-bit (x64). Then, click the .zip button.
Finally, extract the zip file we downloaded.
Go inside the directory and copy the current path. We will use that path to set some environment variables.
For this post, we have the path C:\Users\karldev\Downloads\OpenJDK8U-jdk_x64_windows_hotspot_8u265b01\jdk8u265-b01.
Download Ballerina Zip Distribution
Now, we download the Ballerina zip distribution. Go to Ballerina Download page, click the “Install via the ZIP archive” link which brings us to another page. Then, click Download the Ballerina language ZIP file link.
Go to the directory and copy the current path for later use.
For this post, we have C:\Users\karldev\Downloads\ballerina-1.2.7.
Run Ballerina On Command Line
Open a command-line window, and run the following MS-DOS commands. The first two commands set up environment variables JAVA_HOME and PATH to make Java available in the command-line window.
Then, verify if Java is now available.
We should see the following output.
Next, we make Ballerina available in the command-line windows.
When we try to run Ballerina at this point and we encounter the following error, we need to include the C:\Windows\System32 path in the PATH environment variables.
'findstr' is not recognized as an internal or external command,
operable program or batch file.
To fix this, run the following command.
Now, we can run Ballerina.
That’s how we can run Ballerina on command-line without installing Java. If we need to do the same for the Ballerina IntelliJ plugin, please see IntelliJ IDEA And Ballerina Plugin Configuration.
This is part of the Ballerina Programming Language Tutorial.