0

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?

zmkm
  • 117
  • 1
  • 4
  • If you have non JDK dependencies you should use maven to manage them. See https://stackoverflow.com/questions/46671308/how-to-create-a-java-maven-project-that-works-in-visual-studio-code#:~:text=Open%20the%20Maven%20project%20folder,Executes%20common%20Maven%20commands%22). – tgdavies Apr 23 '22 at 00:59

1 Answers1

0

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.

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13