Compile and Run Kotlin in Command Line

Getting Start with Kotlin in Command Line is the similar as the compile and run Java command line. You can follow the below steps to Compile and Run Kotlin in Command Line.

Download Kotlin Compiler

As you have JDK for the java, you need to download compiler of the kotlin in your computer. You can download Kotlin compiler from here.

Now extract the zip file in your computer anywhere you want.

Now you need to set the path of kotlin’s bin folder in the system environment variables.

Add Kotlin PATH in Windows System Variables

Locate to the bin folder in the kotlin compiler folder.

Now Open System Properties ( Each Windows or OS have own way to access it ) go to Advanced Tab, then click on Environment Variables.

Now Select the PATH variable and click on EDIT.

Now you have to paste the path of bin folder by clicking on ADD NEW.

Now it’s time to compile and run kotlin program in Command Line(CMD).

Compile and Run Kotlin Program

Open your Command Line Interface called as cmd.

Copy the Hello World Program in Kotlin in .kt file and place anywhere in your computer. Locate to that folder where you have placed the .kt file and write kotlinc fileName.kt  to compile the file.

Now write kotlin fileNameKt  to run the file. Note that Kt is attached to each Main File name after compiling. Or you can say main file is compiled in fileNameKt file.