如何让VS代码知道非JDK类的路径?

发布于 2025-01-23 06:56:20 字数 275 浏览 5 评论 0原文

我的Java程序会导入下载的非JDK类,并将其放置在与我的Java文件相同的目录中。我如何让VS代码知道该课程的路径,以免在类未解决的错误下得到红色的红色?

当前,当我编译时,我需要java -cp/path/to/non-jdk/class.jar myclass.java是否有一种方法来添加/path/to/non-jdk/non-jdk/ class.jar到编译器的搜索路径,这样我就可以java myclass.java

My Java program imports a non JDK class downloaded and placed in the same directory as my Java file. How do I let VS Code know the path to this class so I don't get the red under squiggle for class not resolved error?

Currently when I compile I need to java -cp /path/to/Non-JDK/class.jar MyClass.java is there a way to add /path/to/Non-JDK/class.jar to the search path of the compiler so I can just java MyClass.java?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

为人所爱 2025-01-30 06:56:20

您可以单击Java Projects - > 引用的库,它将修改“ java.project.referencelecdlibraries”在settings.json文件中自动自动,或者您可以直接对其进行修改。

enter image description here

You can click Add icon under JAVA PROJECTS -> Referenced Libraries, it will modify "java.project.referencedLibraries" in the settings.json file automatically, or you can modify it directly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文