简体   繁体   English

如何让 VS Code 知道 Non-JDK Classes 的路径?

[英]How to let VS Code know the path to Non-JDK Classes?

My Java program imports a non JDK class downloaded and placed in the same directory as my Java file.我的 Java 程序导入了一个非 JDK class 下载并放在与我的 Java 文件相同的目录中。 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?我如何让 VS Code 知道这个 class 的路径,这样我就不会在 class 未解决错误的波浪线下看到红色?

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 ?目前,当我编译时,我需要java -cp /path/to/Non-JDK/class.jar MyClass.java有没有办法将/path/to/Non-JDK/class.jar添加到编译器的搜索路径所以我只能java MyClass.java吗?

在此处输入图像描述

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.您可以点击JAVA PROJECTS -> Referenced Libraries下的 Add 图标,它会自动修改 settings.json 文件中的"java.project.referencedLibraries" ,也可以直接修改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM