I install kotlin and JDK in Ubuntu 16.04 by following the guidelines here https://kotlinlang.org/docs/tutorials/command-line.html
After that created a file Hello.kt,
but when I run this,
kotlinc Hello.kt -include-runtime -d Hello.jar
I got this error
error: no class roots are found in the JDK path: /usr/lib/jvm/java-9-openjdk-amd64
This is the first time of me so basically I don't have any idea what to do.
Do you have?
Ubuntu 16.04 doesn't have Kotlin in the base repositories, so the default Java installation is unlikely to be Kotlin-aware.
If you use SDKMAN! to install Kotlin, you probably need to use the SDKMAN! installation of Java as well.
sdk install java
sdk install kotlin
Verify that you are not using the Ubuntu-stock Java...
$ which java
~/.sdkman/candidates/java/current/bin/java ## you should see '.sdkman' in the path here
For me, this arose because brew upgrade
removed one jdk version in favor of another.
Gradle, meanwhile, had cached the reference to the jdk version.
I resolved the issue by removing the gradle cache (rm -r .gradle
) and then recompiling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With