LinuxCommandLibrary

kotlinc

kotlin compiler

TLDR

Compile Kotlin file

$ kotlinc [file.kt] -include-runtime -d [output.jar]
copy
Compile to class files
$ kotlinc [file.kt] -d [output_dir]
copy
Compile multiple files
$ kotlinc [file1.kt] [file2.kt] -d [output.jar]
copy
Add classpath
$ kotlinc -cp [lib.jar] [file.kt] -d [output.jar]
copy
Compile with JVM target
$ kotlinc -jvm-target [17] [file.kt] -d [output.jar]
copy

SYNOPSIS

kotlinc [options] files

DESCRIPTION

kotlinc is the command-line Kotlin compiler that translates Kotlin source files (.kt) into JVM bytecode. It can produce either standalone JAR files with the Kotlin runtime bundled via the `-include-runtime` flag, or output class files to a directory for integration with existing build pipelines.
The compiler supports full interoperability with Java, allowing Kotlin code to call Java libraries and vice versa. It accepts a target JVM version through the `-jvm-target` option, supports adding external dependencies via the classpath, and can compile multiple source files together. For larger projects, build tools like Gradle or Maven are typically preferred, but kotlinc is useful for quick compilation tasks, learning, and scripting workflows.

PARAMETERS

FILES

Kotlin source files (.kt).
-d OUTPUT
Output JAR or directory.
-include-runtime
Include Kotlin runtime.
-cp PATH
Classpath.
-jvm-target VERSION
Target JVM version.
-no-stdlib
Don't include stdlib.
--help
Display help information.

CAVEATS

Requires JVM. Slow startup. Consider Gradle for projects.

HISTORY

kotlinc is the official compiler for Kotlin, created by JetBrains as a modern JVM language.

SEE ALSO

kotlin(1), javac(1), gradle(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community