Testing the installation

Let's test if the Kotlin compiler was compiled properly, and added to the environment variables, by running a simple Hello World program.

Here is a simple Hello World program. I'm pretty sure you will notice this in the following Kotlin code, but there is no difference in the language syntax or standard library functions, as shown in the following code snippet:

    fun main(args: Array<String>) {      println("Hello World!")    }

Save this program in a Kotlin file named Hello.kt.

To run the program, we use the kotlinc command, as follows:

kotlinc hello.kt -o hello

In the preceding code, hello.kt is the name of the file containing the Kotlin code and -o hello specifies the output filename.

For an optimized compilation, use the ...

Get Kotlin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.