Using VS Code for Java debugging, there must be projectName
defined in the launch.json file for using the watch-window while debugging.
How to determine and/or define the name of the Java project?
I always get the error message:
Failed to resolve classpath: The project '??' is not a valid java project.
Here my launch.json extract:
"type": "java",
"name": "Debug (Launch)-Application<foo>",
"request": "launch",
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopOnEntry": false,
"mainClass": "FooClass",
"args": "",
"projectName": "??",
"windows": {
"classPaths": [
"%CLASSPATH%","C:\\JUnit\\junit-4.12.jar", "C:\\JUnit\\hamcrest-junit-2.0.0.0.jar", "."
]
}
Once you have opened the folder, click on the Explorer icon on the top left corner of the VSCode (or press Ctrl+Shift+E) to open the explorer panel. In the explorer panel, click on the New File button as shown in the following screenshot: Then simply type in the new file name . env ...
For Maven projects(at least) you can find the project names at the bottom of the vscode sidebar under MAVEN PROJECTS. You can also look for . project files inside your projects. The projectName is there in the name attribute.
The launch. json file is located in a . vscode folder in your workspace (project root folder).
To create a launch. json file, click the create a launch. json file link in the Run start view. If you go back to the File Explorer view (Ctrl+Shift+E), you'll see that VS Code has created a .
i was going crazy trying to figure out why the update i made to .project and pom.xml didn't change the project name in vs code...
edit projectDescription / name in .project
edit artifactId in pom.xml
here's what i did to get it to reload and show the updated project name:
https://github.com/Microsoft/vscode-java-debug/blob/main/Troubleshooting.md#failed-to-resolve-classpath
The VSCode contains JAVA PROJECTS on the sidebar. I am using SSH plugin to connect to a machine where the project actually resides (VS Code runs locally) so the name of the java project is my name and some hash to it
After adding the hash "_c4503cca" to the projectName in launch.json, the watches in debug mode work fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With