Installing Kotlin and First Program

Ways to Run Kotlin

OptionBest for
IntelliJ IDEA (Community is free)learning Kotlin and backend development
Android StudioAndroid apps (Kotlin is built in)
Kotlin Playground (play.kotlinlang.org)quick experiments in the browser, no install
Command-line compiler kotlincunderstanding how compiling works

Kotlin needs a JDK (Java Development Kit) because it runs on the JVM. JDK 17 or 21 is a good choice.

IntelliJ IDEA Steps

  1. Install a JDK (for example Temurin 21) and IntelliJ IDEA Community.
  2. Choose New Project → Kotlin, build system Gradle (Kotlin DSL), JDK 21.
  3. Open src/main/kotlin/Main.kt.
  4. Click the green ▶ next to fun main() to run it.

Command Line

Compile and Run

Save the code as hello.kt, compile it into a runnable jar and run it with Java:

kotlinc hello.kt -include-runtime -d hello.jar
java -jar hello.jar

Example output

Welcome to Careeroza Kotlin!

Example

This is the hello.kt file used above.

fun main() {
    println("Welcome to Careeroza Kotlin!")
}

Output

Welcome to Careeroza Kotlin!