DEV Community

nshmura
nshmura

Posted on

1 1

[Kotlin] ::class.java “Unresolved Reference: Java” error

I got “Unresolved Reference: Java” error in following code.

val clazz = String::class.java
Enter fullscreen mode Exit fullscreen mode

Loading kotlin-reflect library in build.gradle resolved this error.

dependencies {
    ...
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    // this line
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    ...
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post