VSCode调试java控制台输入:Evaluation failed because the thread is not suspended
使用 VS Code 调试 Java 程序,需要使用控制台输入,结果一直报错,找了一下解决方案
报错如下:
在 .vscode/launch.json
添加一行 "console": "externalTerminal"
即可
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch)-main<test>",
"request": "launch",
"mainClass": "main.main",
"projectName": "test",
"console": "externalTerminal"
}
]
}
运行效果如下:
出现此报错的原因是:VSCode 的内置调试控制台不支持 Java 输入。所以需要在debug配置文件里修改调试控制台,只需将 console 属性修改为 externalTerminal 即可。即外置终端。