我在 VScode 中远程调试 java 应用程序,由于某种原因,我无法在调试过程中检查变量的值
如您所见,我正在尝试观察变量“serverMessages”,但是设置变量后我收到错误
Cannot evaluate because of compilation error(s): serverMessages cannot be resolved to a variable.
我的 launch.json 如下所示:
{
// 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": "Attach to Remote Program",
"request": "attach",
"hostName": "localhost",
"port": 51000
},
]
}
我使用以下命令启动应用程序
java -jar ../server.jar -l ../levels/SAD1.lvl -c "java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:51000,quiet=y searchclient.SearchClient -bfs" -g -s 150 -t 180
我不确定我还应该提供哪些其他信息。有谁知道为什么会发生这种情况?
没有使用 -g 选项编译代码可能会解释这一点。 (本地 VSCode 会处理这个问题,但您必须使用 java 调试标志或等效配置来配置构建过程)。