How to Install Kotlin on Linux?
Last Updated :
29 Oct, 2022
Kotlin is a programming language introduced by JetBrains in 2011, the official designer of the most intelligent Java IDE, named Intellij IDEA. This is a strongly statically typed general-purpose programming language that runs on JVM. In 2017, Kotlin is sponsored by Google, announced as one of the official languages for Android Development.
In this article, we will learn How can we install the Kotlin programming language in Linux.
Installing Kotlin on Linux:
Follow the below steps to install Kotlin on your Linux system.
Step 1: Upgrade Packages
Open your Linux terminal and update your package information from all configured sources.
# sudo apt update

Step 2: Install JDK
Install the Java Software Development Kit (JDK). Kotlin is based on JDK. JDK is used to compile Kotlin programs. When you run the following command you will be asked to enter Y or N enter Y and click enter.
# sudo apt install default-jdk

Step 3: Install Kotlin using SDKMAN
SDKMAN is an easier way to install Kotlin on UNIX-based systems. After Installing SDKMAN restart your computer.
# curl -s https://get.sdkman.io | bash

Now we will install Kotlin using the following command.
# sdk install kotlin

After executing the above command Kotlin will be installed in your system. Now we will create a Kotlin file and check it by doing compile and run.
Step 4: Create a Kotlin file
Open any editor and write the following code there and save that file with the .kt extension. Here I'm creating a file with Kotlin.kt name.

For creating a file write nano fileName.kt in your terminal. Then write your Kotlin code inside that file and save it using ctrl + x and then press y.

Kotlin
// Function in Kotlin
fun main(args: Array<String>) {
// Print statement
println("GeeksforGeeks")
}
Step 5: Compile Kotlin file
Navigate to that folder in which you have created your Kotlin file and then compile that file using the following command. Replace Kotlin.kt with your file name and The value of the -d option specifies the name of the output file.
# kotlinc Kotlin.kt -include-runtime -d outPutFile.jar

Step 6: Run the Kotlin Program
Now we will check the output by running the following command.
# java -jar outPutFile.jar

Output:
GeeksforGeeks

Similar Reads
How to Install Git on Kali Linux Git is an important version control system that is renowned for its reliability and cooperation capabilities. The process of installing Git on Kali Linux is straightforward and efficient, guaranteeing that it works seamlessly with your development process. We'll carefully walk you through each step
7 min read
How to Install Katoolin on Linux Mint? If you're looking to install Katoolin on Linux Mint, this guide will help you set it up step by step. Katoolin is a powerful tool that allows users to install Kali tools on non-Kali distributions, such as Linux Mint. By following the instructions in this Katoolin installation guide for Linux Mint, y
3 min read
How to Install Kotlin on MacOS? Kotlin is an open-source programming language. It is developed by JetBrains and is designed to be a modern, safe, and efficient language for building modern applications. It is a functional language means it is based on the functional paradigm. It is a compiled language, which means it compiled to b
4 min read
How to Install LISP on Linux? LISP (List programming) is the second-oldest high-level programming language after Fortran. It has a fully parenthesized prefix notation. Installing LISP on Linux:Follow the below steps to install LISP on Linux: Step 1: Install SBCL compiler. Steel Bank Common Lisp (SBCL) is the most common Lisp com
1 min read
How to Install JUnit Libraries on Linux? JUnit is basically a unit testing framework for Java. JAVA provides a JUnit framework for unit testing, unit testing is simply a process by which we ensure that the code works the way it was intended to, i.e. we check individual units of source code, such as functions, methods, and class. And normal
3 min read