0

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
15
  • Is it possible to share the whole project example? Commented Sep 2, 2019 at 12:24
  • 1
    Kotlin's stdlib is not on the classpath when you run your program. It's hard to tell how to fix this without additional information. Commented Sep 2, 2019 at 12:40
  • What kind of additional information should i share ?? @Egor Commented Sep 2, 2019 at 13:26
  • @y.bedrov it is the whole project whats written in question. I am new in this lang. and i was writing basic examples to understand the syntax. Commented Sep 2, 2019 at 13:29
  • You have to add Kotlin support to your project. Which platform did you use? Commented Sep 2, 2019 at 13:57

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Just wrote the same code from the question here using gradle and intArrayOf() works fine. My guess is that the kotlin-stdlib is not on the classpath.
Nope @Eduardomacedo . kotlin-stdlib is already on the classpath. This is a bug. You can check Youtrack
Well, I believe you. Just thought that is a pretty unique bug and that was unlikely for him to be using the same OS as you.
Unique bugs take more time to discover. If @Tolgahantutar install Windows 10 Pro English OP, he will see. You can check history of my question about this bug. It takes 30 days and so many contributes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.