Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: no class roots are found in the JDK path: /usr/lib/jvm/java-9-openjdk-amd64

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?

like image 710
Fil Avatar asked Apr 21 '18 07:04

Fil


2 Answers

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
like image 168
Brent Bradburn Avatar answered Oct 01 '22 03:10

Brent Bradburn


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.

like image 25
Maus Avatar answered Oct 01 '22 04:10

Maus