Kotlin Compiler
raw JSON → 2.3.21 verified Fri May 01 auth: no javascript
The official Kotlin compiler from JetBrains, version 2.3.21. Kotlin is a statically typed programming language that targets the JVM, JavaScript, Wasm, and native platforms. The compiler includes support for multiplatform projects, coroutines, and a rich standard library. Released on a frequent cadence with stable releases every few months and previews. Key differentiators include full interoperability with Java, concise syntax, and safety features like null safety and sealed classes. This package provides the command-line compiler (kotlinc) and is also used as a dependency by build tools like Gradle and Maven.
Common errors
error error: unresolved reference: kotlinx ↓
cause Missing dependency for kotlinx.coroutines or kotlinx.serialization in Gradle/Maven.
fix
Add implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3' (or similar) to build.gradle.
error FAILURE: Build failed with an exception. * What went wrong: Could not set unknown property 'jvmTarget' for task ':compileKotlin' of type org.jetbrains.kotlin.gradle.tasks.KotlinCompile. ↓
cause Using the deprecated compileKotlin closure without typed configuration.
fix
Use tasks.named('compileKotlin', org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { kotlinOptions.jvmTarget = '1.8' }.
Warnings
breaking Kotlin 2.0+ uses K2 compiler by default, which may cause issues with some code that relied on old compiler behavior. ↓
fix Enable K1 compiler via -Xuse-k1 compiler flag or update code to be compatible with K2.
gotcha Using 'kotlin' Gradle plugin version must match compiler version (e.g., Kotlin 2.3.21 plugin requires compiler 2.3.21). ↓
fix Ensure plugin and compiler versions are consistent. Use version catalog or ext.kotlinVersion.
deprecated Kotlin Android Extensions plugin is deprecated in Kotlin 1.8 and removed in 2.0. ↓
fix Migrate to Jetpack View Binding or Compose.
Install
npm install kotlin-compiler yarn add kotlin-compiler pnpm add kotlin-compiler Imports
- kotlin wrong
import org.jetbrains.kotlin.*correctimport kotlin.* - kotlinx.coroutines wrong
import kotlin.coroutines.*correctimport kotlinx.coroutines.* - KotlinCompile task (Gradle) wrong
compileKotlin { kotlinOptions.jvmTarget = "1.8" }correcttasks.withType<KotlinCompile> { kotlinOptions.jvmTarget = "1.8" }
Quickstart
// hello.kt
fun main() {
println("Hello, Kotlin!")
}
// Compile: kotlinc hello.kt -include-runtime -d hello.jar
// Run: java -jar hello.jar