How can I run kotlin script from command line? Without maven, gradle or kotlin-DSL-gradle, only command line options.
I have two kotlin files in the play folder
user.kt
data class User(val name: String)
play.kts
fun main() {
val user = User("Jim")
println("Hello ${user.name}")
}
It doesn't work
kotlinc -script play.kts
error: unresolved reference: User (play.kts:4:14)
play.kts:4:14: error: unresolved reference: User
val user = User("Jim")
But if I rename it to play.kt and run with command below it works.
kotlinc . -include-runtime -d play.jar && java -jar play.jar
Why it is so, and how to make it work?