Skip to content

Debugging standalone Java files in VSCode returns ClassNotFoundException #344

Description

When the users open pure Java files in VSCode, and debug it, sometimes they get ClassNotFoundException. But if they remove the workspace cache or open all relevant .java files in Editor, the issue disappears.

This issue is involved with single file support. Currently we use a default project jdt.ls-java-project to link the pure Java files, it looks like the link mechanism is error-prone.

Below comments are copied from Gitter chat room.

CJ Bailey CJ Bailey (@cjbailey) Jul 25 17:50
Hi all. I had this extension working perfectly yesterday but today I keep getting the "class not found" exception (nothing has changed since yesterday). Now I can't even uninstall the extension, it just seems to hang.

CJ Bailey CJ Bailey (@cjbailey) Jul 25 18:02
ok, so that's interesting. Finally managed to uninstall and re-install the Java extension pack (including debugger), but still kept getting various class not found exceptions when trying to run the code. It turns out, if I open up all the relevant .java files in the editor first and then hit F5, it works!

CJ Bailey CJ Bailey (@cjbailey) 23:05
I am finding that many times when I get the "cannot find main class" error, deleting the workspace cache and re-opening VS Code seems to get rid of it (normally then revealing different errors in my code, which I'm not even sure are my fault or not - being the noob to Java that I am).

CJ Bailey CJ Bailey (@cjbailey) 23:11
For info, I'm trying not to use Maven or Gradle to begin with. I prefer the unadulterated Java experience while I'm learning the basics tbh.

Activity

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions