问题
When I try to compile some basic array code I get errors. I tried to re-install IntelliJ and I made all updates.
fun main(args: Array<String>) {
val numbers = intArrayOf(1, 4, 42, -3)
if (4 in numbers) {
println("numbers array contains 4.")
}
}
Here are the errors.
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/KotlinPackage
at KtlneKt.main(ktlne.kt:2)
at KtlneKt.main(ktlne.kt)
Caused by: java.lang.ClassNotFoundException: kotlin.KotlinPackage
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
Process finished with exit code 1
回答1:
Same question. So same answer: I had the same problem and I discovered that this is a bug of Kotlin library. You cannot call intArrayOf()
method.
I am sure that you are using Windows 10 Single Language Turkish. (I was using the same operating system.) Kotlin's some libraries cannot work on Turkish operating system. You can check this issue on YouTrack.
You can solve your problem with installing Windows 10 Pro English or Windows 10 Single Language English. I do not know any other approach right now. (You can open new issue on Kotlin website.)
This bug took from me 30 days. You can check my related question about this Kotlin bug.
来源:https://stackoverflow.com/questions/57755750/how-can-i-solve-the-array-problem-in-kotlin