Create, Compile and Run the Hello World Program in Kotlin
Kotlin programs can be written in a very easy manner, follow the below two steps to create, compile and run the program.
1. Open a text editor, write the following "Hello World" program and save the file with .kt extension i.e. HelloWorld.kt
Note: The file name should be the same as the class name with extension .kt - for example, if the class name is HelloWorld then the file name should be HelloWorld.kt
Hello World Program - HelloWorld.kt
fun main(args: Array<String>) {
println("Hello World")
}
2. Compile the kotlin file (i.e. kotlin program) using the command kotlinc HelloWorld.kt -include-runtime -d HelloWorld.jar and execute the compiled byte code using the command java -jar HelloWorld.jar