LAST UPDATED: JUNE 24, 2020
Kotlin Environment Setup
In this tutorial, we’ll discuss how to set up the Kotlin environment in your local machine. You can either setup the command line tool to run Kotlin programs or install IntelliJ IDEA Integrated Development Environment (IDE).
For any programming language, it is preferred to use an IDE as it provides many features over simple text editors. For Kotlin, the most popular IDE is IntelliJ IDEA. IntelliJ IDEA is built by the same company which developed Kotlin, JetBrains.
Setup IntelliJ IDEA
To set up IntelliJ IDEA, follow these steps:
-
Now, choose your operating system and download the Community version as shown in the image above.
-
Run the downloaded executable file. You’ll see this screen:
Click on Next.
-
Again, click on next. If you want to install it anywhere else, select destination and then click on next.
-
Now, this window will appear:
According to your system, select 32-bit launcher or 64-bit launcher . Select all other options and click on next.
-
Click on install, IDE will be installed successfully.
You’ve successfully installed IntelliJ IDEA in your system. If you search it in start, you’ll be able to see it.
Setup command line compiler
If you are running a low configuration system (<= 1GB RAM) or still want to use text editor and command line tool for running your Kotlin code, here is a guide how to install command line tool and run it. For running Kotlin program, you require Kotlin compiler and Java Development Kit (JDK) in your system.
First, we’ll download and setup Kotlin compiler:
-
The first step is to download Kotlin compiler. Open this github link. You’ll see something like this:
Scroll down and download “kotlin-compiler-xx” from Assets section, as shown here:
-
Unzip the downloaded file.
-
In extracted folder navigate to bin folder inside kotlinc folder and copy the path. It will be something like: “C:\Users\deepak\Downloads\kotlin-compiler-1.3.72\kotlinc\bin”. We’ve to set this path as environment variable.
-
In start menu type “Edit the system environment variables” and open it.
-
This window will be opened:
-
Click on Environment Variables.
-
In “Systems Variables” find variable "Path", double click on it. A new window will appear. Now, click on “new” button. Paste the path of bin folder here and click on ok button.
Now we download and setup Java Development Kit (JDK):
-
Open this link to download Java Development Kit. You’ll see a similar window like this:< =/p>
-
Click on “JDK Download” (marked with red arrow). A new window will be opened.
-
Scroll down and download the suitable installer according to your operating system. For windows, choose this one:
-
Unzip the downloaded file.
-
In the extracted folder navigate to the bin folder and copy the path. It will be something like: "C:\Users\deepak\Downloads\jdk-14.0.1_windows-x64_bin\jdk-14.0.1\bin". This path needs to be set as an environment variable also.
-
Follow the same steps to set this path as an environment variable.
Now we’ve successfully setup the Kotlin compiler. To check if everything is working fine, open command prompt, and type the following command:
kotlinc -help
If you observe something like this:
Then everything is running as expected.
Summary
You’ve successfully installed the environment to write your Kotlin programs. We’ll develop our first project and our first program in next tutorial.