Kotlin is a general-purpose programming language which interoperates fully with Java. Kotlin's JVM version of its standard library depends on the Java Class Library, hence this tutorial will first show the reader how to install Java SDK and then a Kotlin compiler on Ubuntu 20.04.

In this tutorial you will learn:
  • How to install Java SDK
  • How to install Kotlin compiler
  • How to compile simple Kotlin program
  • How to run Kotlin program
Kotlin on Ubuntu 20.04 Focal Fossa Linux
Kotlin on Ubuntu 20.04 Focal Fossa Linux

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Installed Ubuntu 20.04 or upgraded Ubuntu 20.04 Focal Fossa
Software Kotlin Compiler, OpenJDK java
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

How to install Kotlin on Ubuntu 20.04 step by step instructions


SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


  1. Install desired Java version. For example in this case we will go with Java openjdk-11-jdk:
    $ sudo apt install openjdk-11-jdk
    
  2. Next step is to install Kotlin:
    $ sudo snap install --classic kotlin
    
  3. Use any text editor and create a file called hello.kt with the following content:
    fun main() {
        println("Hello World!")
    }


  4. Compile the Kotlin source code:
    $ kotlinc hello.kt -include-runtime -d hello.jar
    
  5. Run the actual Kotlin program:
    $ java -jar hello.jar
    Hello World!
    
FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions