skip to Main Content

I have a .jar file I need in order to run my program, and VSCODE doesn’t recognize it as a package, when compiling my project.

I opened a settings.json file with these lines:
" { "java.project.referencedLibraries": [ "biuoop-1.4.jar" ] }"

And added the .jar file to the referenced libraries of the project. I expected it to work, since it stopped showing me errors. But it still doesn’t, and gives this message when compiling:

`AbstractArtDrawing.java:1: error: package biuoop does not exist
import biuoop.GUI;
             ^
AbstractArtDrawing.java:2: error: package biuoop does not exist
import biuoop.DrawSurface;
             ^
AbstractArtDrawing.java:8: error: cannot find symbol
    GUI gui = new GUI("AbstractArtDrawing", 400, 300);
    ^
  symbol:   class GUI
  location: class AbstractArtDrawing
AbstractArtDrawing.java:8: error: cannot find symbol
    GUI gui = new GUI("AbstractArtDrawing", 400, 300);
                  ^
  symbol:   class GUI
  location: class AbstractArtDrawing
AbstractArtDrawing.java:12: error: cannot find symbol
        DrawSurface d = gui.getDrawSurface();
        ^
  symbol:   class DrawSurface
  location: class AbstractArtDrawing
5 errors`

2

Answers


  1. Java > 8 enforces a form of package & module structure unless you directly tweak the behavior directly with javac.

    also it is better for you as a professional to adhere to that structure. so please read up on how to package your jar as a module. there you are able to specify which components of your lib are exposed for access from outside, rather than using classpath directly.

    Login or Signup to reply.
  2. Place the .jar file in Referenced Libraries under the JAVA PROJECT panel.

    enter image description here

    https://code.visualstudio.com/docs/java/java-project#_dependency-management

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