You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In launch mode, the debugger will auto resolve the classpath based on the given mainClass and projectName, but the mechanism is often error-prone. Especially when user configure a wrong the mainClass or projectName, it will throw the errors:
Failed to resolve classpath: Main class '.*' doesn't exist in the workspace.
Failed to resolve classpath: The project '.*' is not a valid java project.
Failed to resolve classpath: Main class '.*' isn't unique in the workspace, please pass in specified projectname.
It's better to add pre-validation mechanism to prompt user about the configuration error.
For the error case Failed to resolve classpath: Main class '.*' isn't unique in the workspace, please pass in specified projectname., one possible reason is the search engine caching stale classes. When Java debugger try to search the corresponding project for the specified fully qualified class name, it will cause multiple projects returned. To solve this problem, need keep the search engine always sync with disk files.
I created a few more project, the error is gone but it's running the wrong project, even when I have the main java file open and I click on "Run", as you can see from the output in the Terminal.
Activity
testforstephen commentedon Jul 27, 2018
CJ Bailey (@cjbailey) Migrate your comment to another bug #344
cjbailey commentedon Jul 27, 2018
Thanks. I've deleted my comment from here.
[-]Failed to resolve classpath: xxx[/-][+]Failed to resolve classpath: xyz[/+]testforstephen commentedon Aug 3, 2018
For the error case
Failed to resolve classpath: Main class '.*' isn't unique in the workspace, please pass in specified projectname., one possible reason is the search engine caching stale classes. When Java debugger try to search the corresponding project for the specified fully qualified class name, it will cause multiple projects returned. To solve this problem, need keep the search engine always sync with disk files.testforstephen commentedon Aug 28, 2018
The feature #355 covered most of cases about
fail to resolve classpath. Keep this issue open to track the edge case.testforstephen commentedon Sep 20, 2019
This issue has been fixed, close it.
rajinder-yadav commentedon Oct 25, 2021
I am seeing this issue. I created 3 maven java projects,
and added each to the workspace, when I try to run the 2nd project I created, I see this error.
If I go into each project folder, open vscode, each project compiles and run fine.
To create the projects from vscode
shift+ctrl+p -> java: create project -> maven -> maven-archetype-quickstart
At then end make sure to select, "add to workspace" (you can use shift+ctrl+p to add it later also).
Version: 1.62.0-insider
Commit: 34eeebdd66033633ac22efd5fab928ae37916168
Date: 2021-10-15T05:15:40.814Z
Electron: 13.5.1
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Linux x64 5.14.11-2-default
rajinder-yadav commentedon Oct 25, 2021
I created a few more project, the error is gone but it's running the wrong project, even when I have the main java file open and I click on "Run", as you can see from the output in the Terminal.

testforstephen commentedon Oct 25, 2021
Could you try to clean the workspace?
F1 -> Java: Clean Java Language Server Workspace
If that doesn't work, please open a new issue and provide a sample project to help reproduce the issue.