To start writing some code, create new Kotlin project in IntelliJ:
File → New → Project
Then choose:
Kotlin → Kotlin (JVM) → Next
Name the project, set file system location and choose Java version from dropdown list (Project SDK). After you click on Finish button new empty Kotlin project will be created.
Now, create your first package, steps are the same, as you would do in Java. Right click on src folder in project structure tree → New → Package. Give some meaningful name to it like:
net.milosvasic.fundamental.kotlin
Finally, create your first Kotlin source code file by right clicking on a package you just created and choosing: New → Kotlin File / Class. Give some name to a file, like for example: First, in our case. New created file will appear in your package.
Great! We have now an empty Kotlin file. Lets add some code:
fun main(args: Array<String>) {
println("My first Kotlin application.")
}
This is very simple code that starts console Kotlin application and prints a line of text. As in Java, here we have function called main as entry point of our application. This function does not belong to any class. We will later talk about defining functions, passing arguments and other related stuff.
To run it right click on .kt file and choose Run. You will notice console output when build process is done and application is executed.