Install a compatible JDK and the Kotlin command-line compiler. The JVM runs compiled Kotlin code. Follow the official installation guide, then verify the installation with kotlinc -version. The screenshots below illustrate an older Windows installation. Use the paths and versions for your machine.
A simple example
Run a first program
Start withA source file
Do thisRun the program
ResultReady
Print a single word to check that your tools can run a program.Lesson.kt
fun main() {
println("Ready")
}
Output
Ready
Get a school laptop ready for class
A coding club shares its Windows laptops between classes. Open a fresh terminal and run kotlinc -version. A version line tells the next student that the shell can find the Kotlin tool.
Java Development Kit (JDK) setup on Windows
Open a new terminal and run javac -version. If the command is unavailable, install the tool or check your PATH.
Install the JDK in the following default directory C:\Program Files\Java\jdk1.8.0_221 and you can move the JDK software to another location as per your wish.
Check the JDK is updated the Environment Variable or not, by opening the command prompt and execute the command java -version. It will show the installed JDK's version otherwise follow the below steps to setup the environment variable path.
Set Path of JDK in Windows system environment variables
1. Locate the directory containing javac.exe. Copy its path.
2. Press Windows + R and enter rundll32.exe sysdm.cpl,EditEnvironmentVariables to open Environment Variables.
Alternatively, search Windows for “environment variables”.
3. Under User variables, select Path and choose Edit.
4. Select New, paste the directory you copied, and confirm with OK.
5. Open a new terminal and run javac -version to verify that Windows can find the tool.
6. With the JDK available, configure the language tools next.
Advertisements
Kotlin Standalone Command Line Compiler setup on Windows
Open a new terminal and run kotlinc -version. If the command is unavailable, install the tool or check your PATH.
Unzip the downloaded version of Kotlin Compiler package in the following directory default directory C:\kotlin and you can move the Kotlin Compiler to another location as per your wish.
Check the JDK is updated the Environment Variable or not, by opening the command prompt and execute the command kotlin -version. It will show the installed Kotlin's version.
Set Path of Kotlin Compiler in Windows
1. Locate the directory containing kotlinc.bat. Copy its path.
2. Open the Windows Environment Variables dialog.
3. Select New, paste the directory you copied, and confirm with OK.
4. Open a new terminal and run kotlinc -version to verify that Windows can find the tool.