Could not find or load main class – VS Code

We Are Going To Discuss About Could not find or load main class – VS Code. So lets Start this Java Article.

Could not find or load main class – VS Code

Advertisements
  1. Could not find or load main class – VS Code

    i think you install the Code Runner Extension,so you have a Run icon in the upper right-hand corner,you could try to uninstall it,
    then F1 ->Clean the java language server workspace.,run your code with F5 or the Run above your Main method

  2. Could not find or load main class – VS Code

    i think you install the Code Runner Extension,so you have a Run icon in the upper right-hand corner,you could try to uninstall it,
    then F1 ->Clean the java language server workspace.,run your code with F5 or the Run above your Main method

Solution 1

Advertisements

This is a known issue https://github.com/microsoft/vscode-java-debug/issues/606, https://github.com/eclipse/eclipse.jdt.ls/issues/1137, which caused the new package not recognized during building workspace. It’s expected to be fixed in vscode-java Middle October release.

Current workaround is reload VS Code window, or F1 ->Clean the java language server workspace.

Original Author jinbo wang Of This Content

Solution 2

Advertisements

i think you install the Code Runner Extension,so you have a Run icon in the upper right-hand corner,you could try to uninstall it,

then F1 ->Clean the java language server workspace.,run your code with F5 or the Run above your Main method

Original Author Leo Zhu – MSFT Of This Content

Solution 3

Advertisements

Try editing your .classpath file to show it where your main class is.

An easier, but much more jank method, is to move your .java file to the root of your project directory to help vscode find it.

Original Author SenorC4 Of This Content

Solution 4

Advertisements

If none of the solutions worked, simply re-build your project to generate updated .class file for the class that contains the main method.

Basically, this error means that Java compiler was unable to find the proper .class file, and your source .java has a main method that wasn’t added to the compiled .class yet.

This can be the case mainly for Maven projects.

Original Author Cortex Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment