Why doesn't IntelliJ recognize my main method?

I have:

fun Array<String>.main() {
  println("Hello World")
}

      

I can compile and run it using java main.Main -cp [kotlin-runtime], but there is no "run" button in IntelliJ and I cannot select this file as my main file.

Edit

It is now correctly recognized by IntelliJ since Kotlin 1.1.5.

+3


source to share


2 answers


You should instead use the main top level function

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

      



Extension function (with any name) for array does not work as main method

+7


source


Oh yes, IntelliJ can only identify two kinds of basic methods:



fun main(args: Array<String>) {
}
fun main(vararg args: String) {
}

      

0


source







All Articles