4

I'm using VSCode. I have the following in myApi.kt:

package com.mycompany.myproject.myapi

data class MyClass(
    val accountNumber: String,
    val state: String,
    val country: String
)

...and I have the following in myApp.java:

import com.mycompany.myproject.myapi.*;

MyClass myObject = new MyClass();

Compilation and execution are all fine. The only problem is VSCode gives me a red squigly underline beneath references to MyClass in the java file. Hovering over it, it says:

MyClass cannot be resolved to a type Java(16777218)

I have the Kotlin plug-in installed in VSCode.

How can I get VSCode to recognize this Kotlin class in my java file?

4
  • This is not yet supported based on this open issue github.com/redhat-developer/vscode-java/issues/531 Commented Apr 12, 2019 at 5:38
  • Thanks, @Barry. Go ahead and put that as an answer and I'll accept it. Commented Apr 12, 2019 at 14:11
  • OK. @Jonathan I've done that. Commented Apr 15, 2019 at 1:16
  • 2
    This is super frustrating, vscode works well while debuging using a kotlin configuration but errors on importing kotlin classes on java are a big down. In the other way debugging kotlin and java with intelliJ does not work when using WSL2. Commented Jan 6, 2022 at 9:10

1 Answer 1

4

This is not yet supported based on this open issue

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

1 Comment

There is a PR open to resolve the issue, so help may be on the way: github.com/fwcd/kotlin-language-server/pull/334

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.