skip to Main Content

I’ve setup a Java project in Visual Studio Code. I installed previously a few java extensions :

Extensions

and I can create a program that does Hello World.
In a folder called lib inside the project folder, I copied some jars (lwjgl3) and, although are shown by intellisense when I try to import them, I have an error that says it cannot find the package :

Error

Anything I missed ?

2

Answers


  1. You need to add the jar to your classpath. The classpath is something used by java to find the libraries your program uses. Java looks in each folder/jar archive to find the class files, because it would be slow if it searched every directory on your computer. See this question: What is a classpath and how do I set it?

    Login or Signup to reply.
  2. Add a reference to the package in the following way.

    • Click the plus sign to the right of Referenced Libraries under the JAVA PROJECTS panel

      enter image description here

    • Select the .jar file in the pop-up window.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search