简体   繁体   中英

kotlin IntelliJ IDEA main function not returning anything

I am trying to learn Kotlin. While working my way through Kotlin Bootcamp for Programmers by Google I have encountered an issue with functions.

A simple Hello World function that I have added in separate kotlin script when ran does not return anything.

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

ScreenShot

In addition I am getting warning: WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil

I was able to find solution which requires adding following line to gradle.properties but it seems not to work. org.gradle.jvmargs=-Dkotlin.daemon.jvm.options=--illegal-access=permit

Project JDK is coretto-15, IntelliJ IDEA is up to date. I am also curious why kotlin files have .kts extension while everywhere I look it says it should be .kt

You need to create the Kotlin sources under the src/main/kotlin directory. But you have created in under the src directory, which is not the source root. See alsoKotlin and Java sources.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM