question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cdimitroulascommented, May 4, 2020

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!

1reaction
DonnieWestcommented, May 4, 2020

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:

https://github.com/fwcd/kotlin-language-server/issues/72#issuecomment-512899441

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java Guide: How to Fix "Could not find or load main class"
The "Could not find or load main class" error occurs when the JVM fails to load the main class. This can happen due...
Read more >
Java – “Could Not Find or Load Main Class” Error | Baeldung
In this tutorial, we'll discuss the probable reasons for failure to find the main class. We'll also see how to fix them. 2....
Read more >
Kotlin - Error: Could not find or load main class _DefaultPackage
This was a severe bug (KT-10221) in automatic generation of Launch Configuration in plugin version 0.4.0. It was fixed in 0.5.0 so the ......
Read more >
Here's How to Fix the "Could Not Find or Load Main Class ...
The error “Could not find or load main class” is indeed dreadful and difficult to fix but not impossible. Learn how to prevent...
Read more >
[Solved] Error: Could not find or load main class | Java Hungry
You can not find these kind of errors in java books. ... "Could not find or load main class : XXX" where the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found