Kotlin is a new language by JetBrains. This kotlin tutorial is not meant to explain the language itself, that we will do in the upcoming tutorials. In this tutorial we will see the various ways we can install Kotlin on our workstations!

Note: Before installing Kotlin, make sure you have JDK installed on your computer.

Command Line Installation

You can install and use Kotlin via command line just as you would do with JAVA, although using an IDE like IntelliJ IDEA is preferred, in case you want to run Kotlin via command line, here you go.

Mac

You can install Kotlin on mac using HomeBrew or Mac Ports.

Brew:

MacPorts:

Linux

You can install Kotlin on linux easily using SDKMAN.

Installing IntelliJ IDEA (preferred)

Rather than using Kotlin on command line, it is much preferred to use an IDE, specifically IntelliJ IDEA. This IDE is from the makers of Kotlin itself, JetBrains! It is configured to support Kotlin Completely and also has some add on features like a plugin to convert your JAVA code to Kotlin with just a click of a button. I will be using IntelliJ IDEA throughout this tutorial series, so we will explore more features of this IDE that are tailored towards Kotlin.

Follow these steps:

  1. Download the community edition IntelliJ IDEA from this link and install it.
  2. Go to Preferences -> Plugins -> Browse Repositories -> Search for ‘Kotlin’ -> Make sure the Plugin is installed, if not then click on the ‘Install’ button.
  3. Now create a new project, while setting up the project, in the first screen, under the ‘Add additional libraries and frameworks’, check the check box that says Kotlin (Java)  and proceed.
  4. Done!

kotlin tutorial

Now that you have set up the environment, lets run our first program!

Create a file named Main.kt in src directory if you are using IntelliJ IDEA and anywhere in you computer if you are compiling using command line.

In Main.kt write the code:

If you are using IntelliJ IDEA then click on the Green Run button to compile and run the code.

On command line, navigate to the folder where you have stored the Main.kt file and write the following commands

(To get more details on command line installation go here and for IntelliJ IDEA go here)

If you don’t understand the above code, don’t worry, in the upcoming tutorials we will go in depth and understand the language. After going through the basics of Kotlin we will see how to use Kotlin for developing Android Apps. This kotlin tutorial series is tailored towards Android Developers who want to get started with the language and eventually use it in production, but non-Android developers can also go through these tutorials as the Android specific tutorials will be kept separate.

 

Next Tutorial “Getting Started with Kotlin – Tutorial 1- Basic Syntax, Variables and Data Types” >>

Leave a Reply

Your email address will not be published.

20 − 16 =