I've downloaded the Jsoup Java library for use in VS Code. I've clicked Referenced Libraries and added the JAR file there. I created this class to see if the imports work:
import org.jsoup.Jsoup;
public class n {
}
When I tried to compile it, I got this error:
javac n.java
n.java:1: error: package org.jsoup does not exist
import org.jsoup.Jsoup;
When I press Ctrl + T and look for some classes, I can see their implementations and all. Why would it not be able to find the package? I already tried compiling with java -cp .:"jsoup-1.17.2.jar" n.java, but it didn't work.
A Step By Step Guide For a PoC JSoup + VSCode Java Project
Based on your input I am not sure what went wrong on your setup, but here is how I made a working PoC Project in VSCode using JDK 11.
Download JSoup Jar
I assume you already did it. I downloaded JSoup 1.17.2 from mvnrepository.com.
Put it in
libdirectory (optional, but a good practice to separate jars from code).Create a Sample Java Class
Save it in the corresponding directory tree:
com/github/tcsizmadia/jsoupsandbox(feel free to rename packages).Compile the Java Class
Your directory tree should look like this:
Run the Compiled Java Class
Result:
Please try these steps on your environment and let us know which step failed so we can narrow down the error.