In Kotlin 1.3.30 I just installed, the main entry function doesn't work in command line. JDK is version 8. Intellij Idea is 2019.1.1. No dependency, very clean project.
When I started learning Kotlin, the main entry is 'fun main(args: Array)'. Last year, 'fun main()' could be used without 'args' and I used it a lot. Now I have a project needs command line parameters, but something goes wrong. I've tried 3 formats:
// 1. doesn't work.
fun main(vararg args: String){
println("this is a test.")
}
// 2. doesn't work
fun main(args: Array<String>){
println("this is a test.")
}
// 3. this works. but where can I get the command line parameters?
fun main(){
println("this is a test.")
}
1 & 2 has same response:
λ java -jar test-1.0-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
at com.yxy.ProgramFileKt.main(ProgramFile.kt)
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
It works fine with 3 without changing any other thing. But I need command line args.