Blog

03/06/2019

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 on Ubuntu or Debian Linux.

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

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

Sample outputs:
Fig.02: Installing kotline

Install JDK

Type the following command :
$ sudo apt-get install openjdk-8-jre-headless
Sample outputs:

[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

For more info see kotlinlang.org.

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

14/08/2019

How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...
14/08/2019

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....
12/08/2019

How to Start and Enable Firewalld on CentOS 7

In this article, we discuss how to start and enable firewalld. It is highly recommended that you have a firewall protecting your server.Pre-Flight CheckThese...