vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

kotlin imports into Java file are unresolved

Open viral-p opened this issue 7 years ago • 28 comments

In a project, there are some interfaces set up in Kotlin, also config files, that are imported into the main Java file. These aren't recognized as valid imports, support for this would be useful. Attempting to move out of IntelliJ to VS Code, this is the only problem with the project.

viral-p avatar May 10 '18 00:05 viral-p

While I can appreciate the problem, Kotlin support is kinda out of scope of our Java support at the moment. We'll need to assess if/how we can help improve the situation. It might come from a companion extension eventually.

fbricon avatar May 22 '18 14:05 fbricon

Currently developing a language server and an extension for Kotlin, I have thought about this.

In a mixed Kotlin-Java Gradle project both languages do recognize dependencies properly. They fail when trying to use classes from the other language though.

An approach to this problem might be to add compiled JVM classes located in the other languages build directory to the classpath.

fwcd avatar Jun 02 '18 21:06 fwcd

Any updates on this?

mrjones2014 avatar Jul 06 '18 14:07 mrjones2014

@fwcd do you have any suggestions on how to implement this either here or in the kotlin language server? you mentioned copying the classfiles around but I'm not sure how to do that manually, let alone code it up.

coffeepac avatar Jul 11 '18 23:07 coffeepac

@coffeepac Implementing that in KotlinLanguageServer first might be easier, because the KLS repo has a smaller codebase and is pretty easy to setup.

Copying any classfiles might not even be necessary, the language server would just have to know where they are located. The Java language server uses the Eclipse project model whilst the Kotlin language server entirely relies on Gradle/Maven, thus placing the classfiles in different locations each.

When scanning the classpath from the Kotlin language server, it would have to search through the directory that the Java language server/the Eclipse project model places the compiled files in.

fwcd avatar Jul 12 '18 13:07 fwcd

Can't wait for using kotlin in VSCode. When can we use kotlin in VSCode?

icelove82 avatar Apr 29 '19 06:04 icelove82

Any updates or news?

CloudyKetchup avatar Oct 11 '19 16:10 CloudyKetchup

This also seems like the last piece for me as well to make VS Code viable for development. I am unable to run Java Junit classes that reference a Kotlin class as it is not able to find the class.

hitoshisatow avatar Jan 28 '20 19:01 hitoshisatow

Yes this is pretty hard since most projects nowadays mix kotlin packages in the import...

ghost avatar Jul 14 '21 00:07 ghost

Hey, just in case anyone might have missed it, I built a prototype companion extension that attempts to solve this issue: https://github.com/fwcd/vscode-java-kotlin We haven't released it yet, but if you really need this you can build it yourself for now.

daplf avatar Jun 27 '22 20:06 daplf

Any updates on this issue?

major7x avatar Dec 15 '22 21:12 major7x

Any updates on this?

mikailcolak avatar Feb 13 '23 11:02 mikailcolak

I follow the others here: are there any updates? I'm having the same problem and it's frustrating over and over again. The program compiles correctly but since the import of Kotlin classes into Java is not supported any reference to a Kotlin class causes many error messages in the error panel, making it very difficult to work. Please can someone consider trying to fix this? Unfortunately I don't have too much knowledge to help more.

gcocevar avatar Feb 24 '23 13:02 gcocevar

Any updates? It's frustrating to have to use IntelliJ for some projects.

linsaftw avatar Mar 30 '23 16:03 linsaftw

Hey everyone. I finally published the companion extension I linked above to make this work: https://marketplace.visualstudio.com/items?itemName=daplf.vscode-java-kotlin

Keep in mind that this is only a prototype for now and I haven't used it with very large projects, but it seems to work well for small ones at least. If you have any problems with the extension, please create an issue. I'm happy to improve it :)

daplf avatar Apr 06 '23 01:04 daplf

Any updates here? Will this feature come at some point?

FelixGSE avatar Aug 10 '23 15:08 FelixGSE

info update

dimaslanjaka avatar Jan 23 '24 12:01 dimaslanjaka

this is necessary, as we mix kotlin and java

Kangmo avatar Mar 09 '24 00:03 Kangmo