Skip to content

Add Kotlin Support: "No main class found" for kotlin projects #63

Open

Description

@vegaed

I have two projects lets call them A and B. B is a library to be used inside of A but for testing I want to be able to start a main that is inside of A this all work in gradle on the command line. I accomplish this by setting the following in project B

springBoot {
mainClassName = 'com.project.A.serverapp'
}

Any way to get this working by using the dashboard.

It also working in debug by setting in launch.json

"mainClass": "com.project.A.serverapp",

Activity

  1. Eskibear commented on Jan 28, 2019

    @Eskibear
    Member

    In this extension, when start a project X, it first searches main classes within this project, and creates an entry in launch.json if not exists, then launches it.
    AFAIK, I don't think the dashboard can help you do that.

  2. vegaed commented on Jan 28, 2019

    @vegaed
    Author

    But I already have an entry in launch.json that works. I use it for debugging. Why can't the dashboard just use that? If there are no main classes within the project fall back to what is in launch.json

  3. consultantdwaraka commented on Jan 31, 2019

    @consultantdwaraka

    I am unable to start the service when I use Kotlin with vscode spring boot dashboard, getting error as "No main class is found" where as it works fine when I use Java.

  4. Eskibear commented on Jan 31, 2019

    @Eskibear
    Member

    I am unable to start the service when I use Kotlin with vscode spring boot dashboard, getting error as "No main class is found" where as it works fine when I use Java.

    Currently it's Java only, it asks Java Debugger about the main class info, and then requests it to launch a debug session. And there is no good Kotlin language server for the moment.

  5. vegaed commented on Jan 31, 2019

    @vegaed
    Author

    So back to why cant the extension just see I have an existing entry in launch.json and use that to start the service?

  6. Eskibear commented on Jan 31, 2019

    @Eskibear
    Member

    Edgardo Vega (@vegaed)
    To be honest, I don't understand your use case very well. If you already have an existing entry in launch.json, and you exactly want to launch that, I think F5 is there for you.

    If there are no main classes within the project fall back to what is in launch.json

    What if I have multiple entries defined in the launch.json? Then which one should it "fall back" to ?

  7. added
    needs more info
    on Mar 26, 2019
  8. no-response commented on Apr 9, 2019

    @no-response

    This issue has been closed automatically because it needs more information and has not had recent activity. Please reach out if you have or find the answers we need so that we can investigate further.

  9. yairkukielka commented on Nov 28, 2019

    @yairkukielka

    any update on this issue? I get the same problem, it doesn't find the main class when it's kotlin. Also, there is actually a Kotlin language server

    I am unable to start the service when I use Kotlin with vscode spring boot dashboard, getting error as "No main class is found" where as it works fine when I use Java.

    Currently it's Java only, it asks Java Debugger about the main class info, and then requests it to launch a debug session. And there is no good Kotlin language server for the moment.

  10. Eskibear commented on Nov 29, 2019

    @Eskibear
    Member

    As I clarified, Kotlin is not supported for the moment. This extension relies on Spring Boot Tools to recognize boot projects, which depends on Language Support for Java.

    To get Kotlin projects working, I think the prerequisites include at least:

    • Find an approach to recognize Kotlin boot projects, distinguish from Java boot projects.
    • Add some logic to delegate corresponding running/debugging tasks to Kotlin extension.

    If you are interested in supporting Kotlin, feel free to discuss and contribute.

  11. added
    enhancement
    and removed
    needs more info
    on Nov 29, 2019
  12. changed the title [-]No main class found[/-] [+]Add Kotlin Support: "No main class found" for kotlin projects[/+] on Nov 29, 2019
  13. deftdawg commented on Sep 8, 2021

    @deftdawg

    I get this error message occasionally on a spring boot project I'm working on (twice in 2 days), it comes on the heels of me stopping a running "spring boot server" and attempting to restart it...

    On the restarting the "spring boot server" this "No main class found." appears and I must go through and manually dirty (make a change or add a comment to the file) and re-save every class used in the project to trigger it to rebuild.

    So this problem isn't specific to kotlin, my app is java / spring boot / maven.

  14. kuercan commented on Dec 20, 2024

    @kuercan

    Wow, it's been five years already, and we're still running into that Kotlin issue. It's still causing us trouble

  15. kuercan commented on Dec 20, 2024

    @kuercan

    As a workaround for Kotlin developers trying to run Spring Boot with this extension, I created a Java main class that calls the Kotlin one.

    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    public class MainApplication {
        public static void main(String[] args) {
            MainKt.main(args);
        }
    }
    
  16. Soap1196 commented on Jul 10, 2026

    @Soap1196
    Contributor

    there is now an official language server for vs code for kotlin from jetbrains. I think headway can be made on adding this capability

  17. Soap1196 commented on Jul 12, 2026

    @Soap1196
    Contributor

    Working on a pr for this now, but noticed this extension relies on the java extension pack to find the main function. There seem to be a few options here. Wait until a kotlin plugin has the ability to make these calls itself, code the functionality directly into the extension, or have the user manually set it up in the .vscode/launch.json file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions