Skip to content
Related Articles

Related Articles

How to Install Kotlin on MacOS?

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Basic
  • Last Updated : 31 Jan, 2022

Kotlin is an open-source programming language. It is developed by JetBrains and is designed to be a modern, safe, and efficient language for building modern applications. It is a functional language means it is based on the functional paradigm. It is a compiled language, which means it compiled to byte code and it is a multi-platform language also, which means that it can be used on JVM, Android, iOS, Linux, macOS, Windows, and other platforms. It is a type-safe language and easy to learn and use. In this article, we are going to learn about the Kotlin language. Let’s learn how we can install Kotlin in our macOS system. Below is the step-by-step guide to installing Kotlin in macOS.

Install Kotlin on MacOS

We can install kotline using any of the following methods:

Method 1: Installing kotlin using IntelliJ IDE

IntelliJ IDEA provides the best support to Kotlin as compared to its command-line compiler and it is easy to use. It provides inbuilt support of Kotlin, you don’t have to download additional components. You can also install Kotlin using Android Studio or Eclipse IDE. Now to install the Kotlin follow the following steps:

Step 1: Download the IntelliJ IDE using the official website.

Visiting-official-website

Step 2: Click on the download button to download community version of IntelliJ IDEA and your download starts automatically.

Click-on-the-download-button

Step 3: Now find the executable file in the Downloads folder(or the place where you download the executable) of your system.

Step 4: Now open the executable file and drag the IntelliJ IDEA to the Application folder for installation.

Open-the-executable-file

Step 5: Now open the IntelliJ IDEA CE from the application panel.

 Application-panel

Step 6: When you open IntelliJ IDEA you will get a dialogue box of IntelliJ IDEA User Agreement. Now check the button to confirm that you have accepted the terms and conditions and then click on the Continue button.

IntelliJ-IDEA-User-Agreement

Step 7: After that, you will get another dialogue box to import IntelliJ IDEA settings. Here if you have previous version data you can import them in your IDEA just like I do and if you do not have then click on “Do not import settings” and then click the OK button.

Import-IntelliJ-IDEA-Settings

Step 8: Now wait for migrating plugins. This step will not appear if you choose Do not import settings. 

Wait-for-migrating-plugins

Step 9: Now your system will ask for permission to open the IntelliJ IDEA CE application.

Now-your-system-will-ask-for-permission

Step 10: Now the welcome box opens here to create a new project click on the New project button.

 Click-on-the-New-project

Step 11: Now in the next window select Kotlin and then you can write the name of your project and can change the location of the project and select Console Application. Now click on the Next button.

Click-on-the-Next-button

Step 12: Now click on the Finish button.

Click-on-the-Finish-button

Step 13: You will see the following interface:

IntelliJ-IDEA-Interface

Now write a simple hello world program in Kotlin:

Kotlin




fun main(args: Array<String>) {
    println("Welcome to GeeksforGeeks!")
}

Now to run the code click on the Run button.

Click-on-the-Run-button.

Now select MainKt.

Now-select-MainKt

You will get the output.

Output-of-the-program

Method 2: Using the brew installer

We can also install Kotline using brew installer. So to install Kotlin follow the following command in the terminal:

brew install kotlin

This will install the Kotlin on the system.

Installing-Kotlin

To run the Kotline program write the code in your favorite edition and save the file with .kt extension. Now to  compile the code follow the following command in the terminal:

$ kotlinc filename.kt -include-runtime -d filename.jar

This will make a .jar file that is runnable and contain the Kotlin runtime library in it. Now to run the application follow the following command:

$ java -jar hello.jar


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!