{"id":25842,"library":"kotlin-compiler","title":"Kotlin Compiler","description":"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.","status":"active","version":"2.3.21","language":"javascript","source_language":"en","source_url":"https://git@github.com/JetBrains/kotlin","tags":["javascript","Kotlin","Language","JavaScript","JVM","JetBrains"],"install":[{"cmd":"npm install kotlin-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add kotlin-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add kotlin-compiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Standard library imports use the 'kotlin' root package. Use 'import kotlin.*' over 'org.jetbrains.kotlin.*' which is for internal compiler APIs.","wrong":"import org.jetbrains.kotlin.*","symbol":"kotlin","correct":"import kotlin.*"},{"note":"Coroutines are in the 'kotlinx.coroutines' package, not 'kotlin.coroutines' (which is for low-level primitives).","wrong":"import kotlin.coroutines.*","symbol":"kotlinx.coroutines","correct":"import kotlinx.coroutines.*"},{"note":"Use typed task configuration (KotlinCompile) instead of the untyped 'compileKotlin' for better IDE support.","wrong":"compileKotlin { kotlinOptions.jvmTarget = \"1.8\" }","symbol":"KotlinCompile task (Gradle)","correct":"tasks.withType<KotlinCompile> { kotlinOptions.jvmTarget = \"1.8\" }"}],"quickstart":{"code":"// hello.kt\nfun main() {\n    println(\"Hello, Kotlin!\")\n}\n\n// Compile: kotlinc hello.kt -include-runtime -d hello.jar\n// Run: java -jar hello.jar","lang":"typescript","description":"Shows basic compilation of a Kotlin source file to a runnable JAR using the command-line compiler."},"warnings":[{"fix":"Enable K1 compiler via -Xuse-k1 compiler flag or update code to be compatible with K2.","message":"Kotlin 2.0+ uses K2 compiler by default, which may cause issues with some code that relied on old compiler behavior.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure plugin and compiler versions are consistent. Use version catalog or ext.kotlinVersion.","message":"Using 'kotlin' Gradle plugin version must match compiler version (e.g., Kotlin 2.3.21 plugin requires compiler 2.3.21).","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Migrate to Jetpack View Binding or Compose.","message":"Kotlin Android Extensions plugin is deprecated in Kotlin 1.8 and removed in 2.0.","severity":"deprecated","affected_versions":">=1.8.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Add implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3' (or similar) to build.gradle.","cause":"Missing dependency for kotlinx.coroutines or kotlinx.serialization in Gradle/Maven.","error":"error: unresolved reference: kotlinx"},{"fix":"Use tasks.named('compileKotlin', org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { kotlinOptions.jvmTarget = '1.8' }.","cause":"Using the deprecated compileKotlin closure without typed configuration.","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."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}