1. What you need

You can write and run Kotlin in several ways:

For this guide we start with the simplest path, then show local setup.

2. Your first program

Create a file named Hello.kt:

Hello.kt
fun main() {
    println("Hello, Kotlin!")
}

Compile and run from the terminal (after installing the compiler):

bash
kotlinc Hello.kt -include-runtime -d Hello.jar
java -jar Hello.jar
Tip: In IntelliJ IDEA you can just open the file and click the green Run icon next to main. No manual compilation needed.

3. Core concepts in 5 minutes

Variables

Kotlin
val name = "Kotlin"      // immutable (preferred)
var count = 0          // mutable
count += 1

Functions

Kotlin
fun greet(name: String): String {
    return "Hello, $name!"
}

// Single-expression form
fun double(x: Int) = x * 2

Null safety

Kotlin
var a: String = "not null"   // cannot be null
var b: String? = null        // can be null

// Safe call
println(b?.length)

// Elvis operator — provide a default
val len = b?.length ?: 0

Classes & data classes

Kotlin
class User(val id: Int, var name: String)

data class Point(val x: Int, val y: Int)

val p1 = Point(1, 2)
val p2 = p1.copy(x = 10)
println(p1)  // Point(x=1, y=2)

4. Project structure (Gradle)

Most real projects use Gradle. A minimal layout looks like this:

tree
my-app/
├── build.gradle.kts
├── settings.gradle.kts
└── src/
    └── main/
        └── kotlin/
            └── Main.kt

Minimal build.gradle.kts:

build.gradle.kts
plugins {
    kotlin("jvm") version "2.0.21"
}

repositories {
    mavenCentral()
}

dependencies {
    implementation(kotlin("stdlib"))
}

5. Next steps

1

Install the toolchain

Follow the Installation guide to set up the compiler and IDE.

2

Explore language features

Dive into the Coding guide for collections, coroutines, DSLs, and more.

3

Read the docs

Use the Docs overview as a map to official and community resources.