ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://kotlinlang.org/docs/command-line.html |
| Last Crawled | 2026-04-08 03:54:19 (17 hours ago) |
| First Indexed | 2021-02-20 06:15:48 (5 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Kotlin command-line compiler | Kotlin Documentation |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | Edit page
02 April 2026
Every Kotlin release ships with a standalone version of the compiler. You can download the latest version manually or via a package manager.
note
Installing the command-line compiler is not an essential step to use Kotlin. The common approach is to write Kotlin applications using IDEs or code editors with official Kotlin support, such as
IntelliJ IDEA
or
Android Studio
. They provide full Kotlin support right out of the box.
Learn how to
get started with Kotlin in an IDE
.
Install the compiler
Manual install
To install the Kotlin compiler manually:
Download the latest version (
kotlin-compiler-2.3.20.zip
) from
GitHub Releases
.
Unzip the standalone compiler into a directory and optionally add the
kotlinc/bin
directory to the system path. The
bin
directory contains the scripts needed to compile and run Kotlin on Windows, macOS, and Linux.
note
If you want to use the Kotlin command-line compiler on Windows, we recommend installing it manually.
SDKMAN!
An easier way to install Kotlin on UNIX-based systems, such as macOS, Linux, Cygwin, FreeBSD, and Solaris, is
SDKMAN!
. It also works in Bash and ZSH shells.
Learn how to install SDKMAN!
.
To install the Kotlin compiler via SDKMAN!, run the following command in the terminal:
Homebrew
Alternatively, on macOS you can install the compiler via
Homebrew
:
Snap package
If you use
Snap
on Ubuntu 16.04 or later, you can install the compiler from the command line:
Create and run an application
Create a simple console JVM application in Kotlin that displays
"Hello, World!"
. In a code editor, create a new file called
hello.kt
with the following code:
fun
main
(
)
{
println
(
"Hello, World!"
)
}
Compile the application using the Kotlin compiler:
kotlinc hello.kt -include-runtime
-d
hello.jar
The
-d
option indicates the output path for generated class files, which may be either a directory or a
.jar
file.
The
-include-runtime
option makes the resulting
.jar
file self-contained and runnable by including the Kotlin runtime library in it.
To see all available options, run:
kotlinc
-help
Run the application:
java
-jar
hello.jar
note
Compile a library
If you're developing a library to be used by other Kotlin applications, you can build the
.jar
file without including the Kotlin runtime:
Since binaries compiled this way depend on the Kotlin runtime, you should ensure that it is present in the classpath whenever your compiled library is used.
You can also use the
kotlin
script to run binaries produced by the Kotlin compiler:
HelloKt
is the main class name that the Kotlin compiler generates for the file named
hello.kt
.
note
Run the REPL
Run the compiler with the
-Xrepl
compiler option
to have an interactive shell. In this shell, you can type any valid Kotlin code and see the results.
Run scripts
You can use Kotlin as a scripting language. A Kotlin script is a Kotlin source file (
.kts
) with top-level executable code.
To run a script, pass the
-script
option to the compiler with the corresponding script file:
Kotlin provides experimental support for script customization, such as adding external properties, providing static or dynamic dependencies, and so on. Customizations are defined by so-called
script definitions
– annotated kotlin classes with the appropriate support code. The script filename extension is used to select the appropriate definition. Learn more about
Kotlin custom scripting
.
Properly prepared script definitions are detected and applied automatically when the appropriate jars are included in the compilation classpath. Alternatively, you can specify definitions manually by passing the
-script-templates
option to the compiler:
For additional details, see the
KEEP-75
.
What's next?
Create a console application based on Kotlin/JVM
. |
| Markdown | [v2.3.20](https://github.com/JetBrains/kotlin/releases/tag/v2.3.20)
- Solutions
- [Case studies](https://kotlinlang.org/case-studies/)
- Docs
- API
- [Community](https://kotlinlang.org/community/)
- [Teach](https://kotlinlang.org/education/)
- Play
Language
Multiplatform
- [Home](https://kotlinlang.org/docs/home.html)
- [Get started](https://kotlinlang.org/docs/getting-started.html)
- [Take Kotlin tour](https://kotlinlang.org/docs/kotlin-tour-welcome.html)
- What's new in Kotlin
- Language guide
- Development
- Interoperability
- Kotlin for data analysis and AI
- Library guides
- API reference
- Build tools
- Compiler and plugins
- Kotlin compiler
- [K2 compiler migration guide](https://kotlinlang.org/docs/k2-compiler-migration-guide.html)
- [Command-line compiler](https://kotlinlang.org/docs/command-line.html)
- [Create a console app](https://kotlinlang.org/docs/jvm-get-started.html)
- [Compiler options](https://kotlinlang.org/docs/compiler-reference.html)
- [Compiler execution strategy](https://kotlinlang.org/docs/compiler-execution-strategy.html)
- Kotlin compiler plugins
- Compose compiler
- Kotlin Symbol Processing API
- Kotlin evolution and roadmap
- Early access preview (EAP)
- Learning materials
- Other resources
1. [Compiler and plugins](https://kotlinlang.org/docs/command-line.html#0)
2. [Kotlin compiler](https://kotlinlang.org/docs/command-line.html#0)
3. [Command-line compiler](https://kotlinlang.org/docs/command-line.html#0)
# Kotlin command-line compiler
[Edit page](https://github.com/JetBrains/kotlin-web-site/edit/master/docs/topics/compiler/command-line.md)02 April 2026
Every Kotlin release ships with a standalone version of the compiler. You can download the latest version manually or via a package manager.
> ### note
> Installing the command-line compiler is not an essential step to use Kotlin. The common approach is to write Kotlin applications using IDEs or code editors with official Kotlin support, such as [IntelliJ IDEA](https://www.jetbrains.com/idea/) or [Android Studio](https://developer.android.com/studio). They provide full Kotlin support right out of the box.
>
> Learn how to [get started with Kotlin in an IDE](https://kotlinlang.org/docs/getting-started.html).
## Install the compiler
### Manual install
To install the Kotlin compiler manually:
1. Download the latest version (`kotlin-compiler-2.3.20.zip`) from [GitHub Releases](https://github.com/JetBrains/kotlin/releases/tag/v2.3.20).
2. Unzip the standalone compiler into a directory and optionally add the `kotlinc/bin` directory to the system path. The `bin` directory contains the scripts needed to compile and run Kotlin on Windows, macOS, and Linux.
> ### note
> If you want to use the Kotlin command-line compiler on Windows, we recommend installing it manually.
### SDKMAN\!
An easier way to install Kotlin on UNIX-based systems, such as macOS, Linux, Cygwin, FreeBSD, and Solaris, is [SDKMAN\!](https://sdkman.io/). It also works in Bash and ZSH shells. [Learn how to install SDKMAN\!](https://sdkman.io/install).
To install the Kotlin compiler via SDKMAN!, run the following command in the terminal:
```
sdk install kotlin
```
### Homebrew
Alternatively, on macOS you can install the compiler via [Homebrew](https://brew.sh/):
```
brew update
brew install kotlin
```
### Snap package
If you use [Snap](https://snapcraft.io/) on Ubuntu 16.04 or later, you can install the compiler from the command line:
```
sudo snap install --classic kotlin
```
## Create and run an application
1. Create a simple console JVM application in Kotlin that displays `"Hello, World!"`. In a code editor, create a new file called `hello.kt` with the following code:
```
fun main() {
println("Hello, World!")
}
```
2. Compile the application using the Kotlin compiler:
```
kotlinc hello.kt -include-runtime -d hello.jar
```
- The `-d` option indicates the output path for generated class files, which may be either a directory or a .jar file.
- The `-include-runtime` option makes the resulting .jar file self-contained and runnable by including the Kotlin runtime library in it.
To see all available options, run:
```
kotlinc -help
```
3. Run the application:
```
java -jar hello.jar
```
> ### note
> To compile a Kotlin/Native application, use the [Kotlin/Native compiler](https://kotlinlang.org/docs/native-get-started.html#using-the-command-line-compiler).
## Compile a library
If you're developing a library to be used by other Kotlin applications, you can build the .jar file without including the Kotlin runtime:
```
kotlinc hello.kt -d hello.jar
```
Since binaries compiled this way depend on the Kotlin runtime, you should ensure that it is present in the classpath whenever your compiled library is used.
You can also use the `kotlin` script to run binaries produced by the Kotlin compiler:
```
kotlin -classpath hello.jar HelloKt
```
`HelloKt` is the main class name that the Kotlin compiler generates for the file named `hello.kt`.
> ### note
> To compile a Kotlin/Native library, use the [Kotlin/Native compiler](https://kotlinlang.org/docs/native-libraries.html#using-kotlin-native-compiler).
## Run the REPL
Run the compiler with the [`-Xrepl` compiler option](https://kotlinlang.org/docs/compiler-reference.html#xrepl) to have an interactive shell. In this shell, you can type any valid Kotlin code and see the results.
## Run scripts
You can use Kotlin as a scripting language. A Kotlin script is a Kotlin source file (`.kts`) with top-level executable code.
```
import java.io.File
// Get the passed in path, i.e. "-d some/path" or use the current path.
val path = if (args.contains("-d")) args[1 + args.indexOf("-d")]
else "."
val folders = File(path).listFiles { file -> file.isDirectory() }
folders?.forEach { folder -> println(folder) }
```
To run a script, pass the `-script` option to the compiler with the corresponding script file:
```
kotlinc -script list_folders.kts -- -d <path_to_folder_to_inspect>
```
Kotlin provides experimental support for script customization, such as adding external properties, providing static or dynamic dependencies, and so on. Customizations are defined by so-called script definitions – annotated kotlin classes with the appropriate support code. The script filename extension is used to select the appropriate definition. Learn more about [Kotlin custom scripting](https://kotlinlang.org/docs/custom-script-deps-tutorial.html).
Properly prepared script definitions are detected and applied automatically when the appropriate jars are included in the compilation classpath. Alternatively, you can specify definitions manually by passing the `-script-templates` option to the compiler:
```
kotlinc -script-templates org.example.CustomScriptDefinition -script custom.script1.kts
```
For additional details, see the [KEEP-75](https://github.com/Kotlin/KEEP/blob/master/proposals/scripting-support.md).
## What's next?
[Create a console application based on Kotlin/JVM](https://kotlinlang.org/docs/jvm-get-started.html).
Thanks for your feedback\!
Was this page helpful?
Yes
No
- [Kotlin command-line compiler](https://kotlinlang.org/docs/command-line.html)
- [Install the compiler](https://kotlinlang.org/docs/command-line.html#install-the-compiler)
- [Manual install](https://kotlinlang.org/docs/command-line.html#manual-install)
- [SDKMAN\!](https://kotlinlang.org/docs/command-line.html#sdkman)
- [Homebrew](https://kotlinlang.org/docs/command-line.html#homebrew)
- [Snap package](https://kotlinlang.org/docs/command-line.html#snap-package)
- [Create and run an application](https://kotlinlang.org/docs/command-line.html#create-and-run-an-application)
- [Compile a library](https://kotlinlang.org/docs/command-line.html#compile-a-library)
- [Run the REPL](https://kotlinlang.org/docs/command-line.html#run-the-repl)
- [Run scripts](https://kotlinlang.org/docs/command-line.html#run-scripts)
- [What's next?](https://kotlinlang.org/docs/command-line.html#what-s-next)
[K2 compiler migration guide](https://kotlinlang.org/docs/k2-compiler-migration-guide.html)
[Create a console app – tutorial](https://kotlinlang.org/docs/jvm-get-started.html)
[Contributing to Kotlin](https://kotlinlang.org/docs/contribute.html)[Releases](https://kotlinlang.org/docs/releases.html)[Press Kit](https://kotlinlang.org/assets/kotlin-media-kit.pdf)[Security](https://kotlinlang.org/docs/security.html)[Blog](https://blog.jetbrains.com/kotlin)[Issue Tracker](https://youtrack.jetbrains.com/issues/KT)[Brand Assets](https://kotlinlang.org/docs/kotlin-brand-assets.html)[Careers](https://www.jetbrains.com/careers/jobs/#team=Kotlin)[Kotlin Merch](https://www.jetbrainsmerchandise.com/view-all.html?brand=32)[Opt-Out](https://kotlinlang.org/docs/command-line.html#opt-out)
Kotlin™ is protected under the [Kotlin Foundation](https://kotlinlang.org/foundation/kotlin-foundation.html) and licensed under the [Apache 2 license](https://github.com/JetBrains/kotlin-web-site/blob/master/LICENSE).
Supported and developed by [JetBrains](https://www.jetbrains.com/) |
| Readable Markdown | [Edit page](https://github.com/JetBrains/kotlin-web-site/edit/master/docs/topics/compiler/command-line.md)02 April 2026
Every Kotlin release ships with a standalone version of the compiler. You can download the latest version manually or via a package manager.
> ### note
> Installing the command-line compiler is not an essential step to use Kotlin. The common approach is to write Kotlin applications using IDEs or code editors with official Kotlin support, such as [IntelliJ IDEA](https://www.jetbrains.com/idea/) or [Android Studio](https://developer.android.com/studio). They provide full Kotlin support right out of the box.
>
> Learn how to [get started with Kotlin in an IDE](https://kotlinlang.org/docs/getting-started.html).
Install the compiler
Manual install
To install the Kotlin compiler manually:
1. Download the latest version (`kotlin-compiler-2.3.20.zip`) from [GitHub Releases](https://github.com/JetBrains/kotlin/releases/tag/v2.3.20).
2. Unzip the standalone compiler into a directory and optionally add the `kotlinc/bin` directory to the system path. The `bin` directory contains the scripts needed to compile and run Kotlin on Windows, macOS, and Linux.
> ### note
> If you want to use the Kotlin command-line compiler on Windows, we recommend installing it manually.
SDKMAN\!
An easier way to install Kotlin on UNIX-based systems, such as macOS, Linux, Cygwin, FreeBSD, and Solaris, is [SDKMAN\!](https://sdkman.io/). It also works in Bash and ZSH shells. [Learn how to install SDKMAN\!](https://sdkman.io/install).
To install the Kotlin compiler via SDKMAN!, run the following command in the terminal:
Homebrew
Alternatively, on macOS you can install the compiler via [Homebrew](https://brew.sh/):
Snap package
If you use [Snap](https://snapcraft.io/) on Ubuntu 16.04 or later, you can install the compiler from the command line:
Create and run an application
1. Create a simple console JVM application in Kotlin that displays `"Hello, World!"`. In a code editor, create a new file called `hello.kt` with the following code:
```
fun main() {
println("Hello, World!")
}
```
2. Compile the application using the Kotlin compiler:
```
kotlinc hello.kt -include-runtime -d hello.jar
```
- The `-d` option indicates the output path for generated class files, which may be either a directory or a .jar file.
- The `-include-runtime` option makes the resulting .jar file self-contained and runnable by including the Kotlin runtime library in it.
To see all available options, run:
```
kotlinc -help
```
3. Run the application:
```
java -jar hello.jar
```
> ### note
Compile a library
If you're developing a library to be used by other Kotlin applications, you can build the .jar file without including the Kotlin runtime:
Since binaries compiled this way depend on the Kotlin runtime, you should ensure that it is present in the classpath whenever your compiled library is used.
You can also use the `kotlin` script to run binaries produced by the Kotlin compiler:
`HelloKt` is the main class name that the Kotlin compiler generates for the file named `hello.kt`.
> ### note
Run the REPL
Run the compiler with the [`-Xrepl` compiler option](https://kotlinlang.org/docs/compiler-reference.html#xrepl) to have an interactive shell. In this shell, you can type any valid Kotlin code and see the results.
Run scripts
You can use Kotlin as a scripting language. A Kotlin script is a Kotlin source file (`.kts`) with top-level executable code.
To run a script, pass the `-script` option to the compiler with the corresponding script file:
Kotlin provides experimental support for script customization, such as adding external properties, providing static or dynamic dependencies, and so on. Customizations are defined by so-called script definitions – annotated kotlin classes with the appropriate support code. The script filename extension is used to select the appropriate definition. Learn more about [Kotlin custom scripting](https://kotlinlang.org/docs/custom-script-deps-tutorial.html).
Properly prepared script definitions are detected and applied automatically when the appropriate jars are included in the compilation classpath. Alternatively, you can specify definitions manually by passing the `-script-templates` option to the compiler:
For additional details, see the [KEEP-75](https://github.com/Kotlin/KEEP/blob/master/proposals/scripting-support.md).
What's next?
[Create a console application based on Kotlin/JVM](https://kotlinlang.org/docs/jvm-get-started.html). |
| Shard | 133 (laksa) |
| Root Hash | 6318628317363213333 |
| Unparsed URL | org,kotlinlang!/docs/command-line.html s443 |