I have a few questions about the IntelliJ's initial setup for doing the most basic thing in Kotlin. Both are created by the same company, so I thought it would work seamlessly, but it did not.
The new project option "Kotlin -> JVM | IDEA" (which I thought is for "Hello, world" type project) did not create any starting point file. It only created an empty "src" directory. All other project templates (other than explicit "Blank" solution) in all other IDE's included a starting point file and a starting method/class. Why does IntellJ have nothing?
So, I created a new Kotlin class under the "src" directory. Searching Google "kotlin main" gave this page which had
fun main(args: Array) { println("Hello World!") }
but with that, I could not select the main class in the "Kotlin" Run/Debug Configurations. After searching Google, I found that it should be:
companion object {
@JvmStatic fun main(args: Array<String>) {
println("Kotlin main is running here!")
}
}
It worked, but then, what is the one without @JvmStatic above? Is it wrong? Or is it correct? If it is another correct version, why doesn't the "Kotlin" Run/Debug Configurations recognise it?
- After changing it to the @JvmStatic main, the class automatically showed up in the "Search by Name" tab of the "Choose Main Class". But still, I could not select the class in the Project tab. The [OK] button gets disabled. Why is it so? A bug?
IntelliJ IDEA 2020.1.1 (Community Edition). All updated to the latest versions.