我正在使用Visual Studio Code for Java,并且想在使用库时调试代码。但是,每当我开始调试时,都会出现以下错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
IO cannot be resolved
IO cannot be resolved
IO cannot be resolved
at TestClass.main(TestClass.java:6)
例如,带有以下代码:
import AlgoTools.IO;
public class TestClass {
public static void main(String[] args) {
int a, b;
a = IO.readInt("Please enter a number ");
b = IO.readInt("Please enter another number ");
IO.println("Your number is: " + (a + b));
}
}
但是,当我使用javac <Filename>
在cmd或PowerShell中编译我的代码并使用java <Classname>
运行它时,它可以正常工作。当我尝试在Visual Studio Code中进行调试时,只会收到错误消息。
我还应该提到,我在CLASSPATH中将路径添加到了.jar库中。
我正在使用默认的“启动”调试配置:
{
"type": "java",
"name": "Debug (Launch)",
"request": "launch",
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopOnEntry": false,
"mainClass": "",
"args": ""
},
答案 0 :(得分:0)
您应该安装一个名为“ java extension pack”和java maven的扩展。或安装该离线扩展程序。click here and get extension name