How to install kotlin programming language on Ubuntu/Debian Linux

How do I install the latest version of kotlin programming language on Ubuntu or Debian Linux system?

Kotlin is a free and open source statically-typed programming language. It runs on the JVM, and one can compile to JavaScript source code. Kotlin is similar to Apple’s Swift. One can write server-side or Android apps in it. This page shows you how to install the latest version of Kotlin programming language on an Ubuntu or Debian Linux development workstation.

ADVERTISEMENTS

Installing kotlin programming language using snap on Ubuntu (quick method)

If you have snap enabled on Ubuntu, run:
$ sudo snap install kotlin --classic
Outputs:

kotlin 1.4.0 from jetbrains* installed

Now skip to write your first kotlin program.

Install kotlin using the Software Development Kit (SDK) manager

Type the following command to install sdk:
$ wget -O sdk.install.sh "https://get.sdkman.io"
$ vi sdk.install.sh
$ bash sdk.install.sh

Sample outputs:

Fig.01: Installing SDKMAN

Fig.01: Installing SDKMAN

Type the following commands to install kotlin:
$ source ~/.sdkman/bin/sdkman-init.sh
$ sdk install kotlin

Installing kotlin programming language on Ubuntu or Debian Linux

Fig.02: Installing kotline

Install JDK

Use the apt-cache command to search for openjdk packages:
$ sudo apt-cache search openjdk | grep headless
How to setup Kotlin and JDK on Ubuntu and Debian Linux
Type the following command apt-get command or apt command to install JDK:
$ sudo apt-get install openjdk-8-jre-headless

[sudo] password for vivek: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-4.10.0-19 linux-headers-4.10.0-19-generic linux-image-4.10.0-19-generic linux-image-extra-4.10.0-19-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  ca-certificates-java java-common
Suggested packages:
  default-jre fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho ttf-wqy-microhei | ttf-wqy-zenhei fonts-indic
The following NEW packages will be installed:
  ca-certificates-java java-common openjdk-8-jre-headless
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 27.7 MB of archives.
After this operation, 102 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu zesty/main amd64 ca-certificates-java all 20161107 [12.6 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu zesty/main amd64 

Write your first kotlin program

Create a file called hello.kt:
$ vi hello.kt
Append the following code:

fun main(args: Array<String>) {
    println("Hello, World!")
}

Save and close the file. Compile your app into jar:
$ kotlinc hello.kt -include-runtime -d hello.jar
Run your app:
$ java -jar hello.jar
Sample outputs:

Fig.03: Running your first app

Fig.03: Running your first app

For more info see kotlinlang.org.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • fmo Jun 19, 2017 @ 9:05

    Alternatively you can use umake

    sudo apt-get install ubuntu-make

    umake kotlin

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.