简体   繁体   中英

VS Code - The import "#####" cannot be resolved

So, i am running a java project which have many library that are available in the current working directory but VS code seems to not recognize these library and giving out error "The import ###### cannot be resolved" ex: The import org.apache.pdfbox.pdmodel.PDDocument cannot be resolved"

here is the image that might help you to know more about it This is the package that i am working on: Here the org/apache is the library contain the class file that are need to be imported and FileArrangement.java is the file having the import statements

Error i have been receiving this is what VS code is been showing

i really need your help because i really don't have any idea how to correct this

I have checked other projects and they are also showing the same result although the import statements for java classes like. java.util.ArrayList doesn't show any kind of error and i have tried to clean java in VS code it also didn't work

i just need to correct this error of VS code to import the classes that i need No error on java.util package

Putting the libraries in your current working directory does not work for Java, you need to add them to the classpath.

If you're using maven, that manages the classpath for you.

If not, you can manage it in VS Code by executing the Java: Configure Classpath command from the Command Palette (Ctrl+Shift+P).

You can add dependencies via Referenced libraries under the JAVA PROJECTS panel.

在此处输入图像描述

Or use java.project.referencedLibraries setting in settings.json .

For example:

"java.project.referencedLibraries": [
    "library/**/*.jar",
    "/home/username/lib/foo.jar"
]

Details can be found in configure-classpath and manage-dependencies .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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