Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find or load main class org.javacs.kt.MainKt #201

Closed
cdimitroulas opened this issue Apr 22, 2020 · 5 comments
Closed

Could not find or load main class org.javacs.kt.MainKt #201

cdimitroulas opened this issue Apr 22, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@cdimitroulas
Copy link

cdimitroulas commented Apr 22, 2020

Hi there,

Pardon my ignorance as I am completely new to the Java/Kotlin ecosystem and so understand very little about all the tools. I tried to search for similar issues but was unable to find anything which matched the exact problem I'm having. I will try to explain as much about my setup as possible so that it makes it easier for you to help me :)

When I open a kotlin file in nvim using coc, I am unable to start KLS due to the following error:

[Error  - 5:51:04 PM] ~/Programs/kotlin-language-server/server/build/scripts/kotlin-language-server exited with code: 1
Error: Could not find or load main class org.javacs.kt.MainKt
Caused by: java.lang.ClassNotFoundException: org.javacs.kt.MainKt
[Error  - 5:51:04 PM] Connection to server got closed. Server will not be restarted.
[Error  - 5:51:04 PM] ~/Programs/kotlin-language-server/server/build/scripts/kotlin-language-server exited with code: 1

I set up a project by using https://start.spring.io/ and selecting Kotlin, Java 11, Gradle and Spring Boot 2.2.6 with the Web dependency.

I have also installed the Kotlin compiler separately and added it's bin/ folder to my path so kotlinc is available.

I'm able to build the project using ./gradlew build and also run it successfully using ./gradlew bootRun.

If I run java -version on my machine I get the following output:

openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)

Appreciate any help I can get as I would be really happy to continue using vim instead of switching to IntelliJ for a new Kotlin project that I will be a part of!

@DonnieWest
Copy link
Contributor

I think you're using the wrong compiled binary. It should be at kotlin-language-server/server/build/install/server/bin/kotlin-language-server. If you're not seeing it, you'll need to run ./gradlew :server:installDist

@cdimitroulas
Copy link
Author

cdimitroulas commented May 4, 2020

Thanks, you were right I was pointing to the wrong binary. Changing my coc nvim configuration to point to the path you specified made it work.

I'm now encountering an error from the language server so that's a start!

The error I'm seeing is:

[kotlin INLINE_FROM_HIGHER_PLATFORM] [E] Cannot inline bytecode built with JVM target
1.8 into bytecode that is being built with JVM target 1.6. Please specify proper
'-jvm-target' option

How can I fix this?

Please let me know if I should move this question somewhere else like StackOverflow or a new issue as it's unrelated to the original issue I raised.

@DonnieWest
Copy link
Contributor

I'm not sure how coc works, but you should be able to provide a config of some sort to your LSP provider. Here's a solution from another issue:

#72 (comment)

@cdimitroulas
Copy link
Author

Thanks for the pointer, I should be able to find a way to configure that in my editor.

Please close this issue and thanks for your help it's much appreciated!

@fwcd fwcd added the bug Something isn't working label May 27, 2020
@fwcd
Copy link
Owner

fwcd commented May 27, 2020

I'm going to close this issue, since I assume your problem was resolved. If not, feel free to reopen. ^^

@fwcd fwcd closed this as completed May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants