[英]Java compile error in Visual Studio Code: Could not find or load main class
I mistakenly executed those two lines on console:我错误地在控制台上执行了这两行:
rm -rf ~/Library/Application\ Support/Code/Cache/*
rm -rf ~/Library/Application\ Support/Code/CachedData/*
I hoped to clear cache to improve speed, but then I discovered that it deletes some key files and I failed debug my java file every time after then which said:我希望清除缓存以提高速度,但后来我发现它删除了一些关键文件,之后我每次调试我的 java 文件都失败了,它说:
bash-3.2$ /Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home/bin/java --enable-preview -Dfile.encoding=UTF-8 -cp /private/var/folders/58/tqd41r6x5rlfzms1y1rx7s_m0000gn/T/vscodesws_cb741/jdt_ws/jdt.ls-java-project/bin Test Error: Could not find or load main class Test Caused by: java.lang.ClassNotFoundException: Test
bash-3.2$ /Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home/bin/java --enable-preview -Dfile.encoding=UTF-8 -cp /private/var/folders/58/ tqd41r6x5rlfzms1y1rx7s_m0000gn/T/vscodesws_cb741/jdt_ws/jdt.ls-java-project/bin 测试错误:无法找到或加载主要 class 测试原因:Z93F725A07423NotClassException:TestLangException:F448。
Could not find or load main class?无法找到或加载主 class? But in the file the main class is right declared and I successfully ran before the problem occurred.
但是在文件中,主要的 class 是正确声明的,我在问题发生之前成功运行。
Thank you very much!非常感谢!
I figured out at last.我终于想通了。 Just open a folder and you can do for free.
只需打开一个文件夹,您就可以免费进行。 Also, don't change setting.json.
此外,请勿更改设置。json。 After I reinstalled macOS...(Yes, there's no mistake here) I got a right setting.json and here's its code:
在我重新安装 macOS 之后......(是的,这里没有错误)我得到了正确的设置。json,这是它的代码:
{
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"java.errors.incompleteClasspath.severity": "ignore",
"files.autoSave": "afterDelay",
"java.configuration.checkProjectSettingsExclusions": false,
"git.confirmSync": false,
"git.enableSmartCommit": true,
"terminal.integrated.lineHeight": 0,
"python.jediEnabled": false
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.