Forrest logo
back to the kotlinc tool

kotlinc:tldr:d4290

kotlinc: Compile a Kotlin file into a self contained jar file with the Kotlin runtime library included.
$ kotlinc ${filename-kt} -include-runtime -d ${filename-jar}
try on your machine

This command is used to compile Kotlin source code into a standalone executable JAR file.

Here is a breakdown of the different parts of the command:

  • kotlinc: This is the command to run the Kotlin compiler.
  • ${filename-kt}: This is a placeholder for the Kotlin source code file name. The ${filename-kt} part needs to be replaced with the actual name of the Kotlin source code file that you want to compile.
  • -include-runtime: This option tells the Kotlin compiler to include the Kotlin runtime library in the JAR file. The Kotlin runtime library contains the necessary classes and functions to run Kotlin code.
  • -d ${filename-jar}: This option specifies the output file name for the compiled JAR file. The ${filename-jar} part needs to be replaced with the desired name of the JAR file that will be generated by the Kotlin compiler.

To use this command, you need to have the Kotlin compiler (kotlinc) installed on your system, and you need to replace the ${filename-kt} and ${filename-jar} parts with the appropriate file names. After executing this command, the Kotlin source code will be compiled, and a JAR file containing the compiled code and the Kotlin runtime library will be generated.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the kotlinc tool