vscode java总是报错,VSCode Java调试器“错误无法打开'thing.java':找不到文件(\thing.java)。”...

I am receiving this error when try to debug java in VSCode:

Error Unable to open 'thing.java': File not found (\thing.java).

The debugger seems to be running (my code is paused, I can see local variables and step through, but the source code is not being shown).

Here is my launch.json:

{

"name": "Java",

"type": "java",

"request": "launch",

"stopOnEntry": true,

"preLaunchTask": "build",

"jdkPath": "${env:JAVA_HOME}/bin",

"cwd": "${workspaceRoot}",

"startupClass": "my.package.classname",

"options": [

"-classpath",

"${workspaceRoot}/bin"

]

}

What am I doing wrong? How can I get the source code to show?

解决方案

It appears javaVSCode (Java debugger for VSCode) is having trouble locating the source files. This was an issue for this, and it appears to be fixed.

Unfortunately there was no documentation. So, after looking through the merge and some experimentation, the answer is to:

Add the "sourcePath" option to your configuration

eg.

{

"name": "Java",

"type": "java",

"request": "launch",

"stopOnEntry": true,

"preLaunchTask": "build",

"jdkPath": "${env:JAVA_HOME}/bin",

"sourcePath": ["${workspaceRoot}/src/my/package"],

"cwd": "${workspaceRoot}",

"startupClass": "my.package.classname",

"options": [

"-classpath",

"${workspaceRoot}/bin"

]

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值