If you want to write the main function without any parameters, it has to be outside of the class like this:
package org.example
fun main() {
println("Hello World!")
}
Note that in this case, the main function will be inside an artificial implicit class that is called like the containing file suffixed with Kt. This means, that in your example where you place the main function inside a file AppKt.kt, the resulting main class is called AppKtKt.
If you want to have the main function inside a class, you have to specify a parameter for the arguments. Also, it needs to be static, i.e. it has to be inside an object and must be annotated with @JvmStatic.
This can be done by declaring an object:
object AppKt {
@JvmStatic
fun main(args: Array<String>) {
println("Hello World!")
}
}
Or you can put the main function inside the companion object of a class:
class AppKt {
companion object {
@JvmStatic
fun main(args: Array<String>) {
println("Hello World!")
}
}
}