I am currently trying to make a web-scraping program with jsoup. However, everything I have imported does not seem to show up when I compile my program, and it errors out saying it can't find any objects that I reference from jsoup.
This is how I imported it:
`
import java.io.*;//for website
import java.net.URL;//retrieve url
import java.util.logging.Level;//log errors
import java.util.logging.Logger;
import java.io.*; //I/O stream
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jsoup.Jsoup;//web scraper
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.net.URL;`
And these are the types of errors I'm getting:
Images.java:25: error: cannot find symbol
for(Element el : img){// for each element, get source (src) url
Where Element from jsoup cannot be found.
This is my environment variable set up, since I thought that would have to do with it.
This issue is very weird to me, because I seem to be importing everything correctly. I also have the jsoup.jar and the extracted jsoup files in the root directory of my project, if that is the correct way to do it. I am using the java10SDK to compile through cmd, and I have have tried using intelliJ ultimate to use their dependency injection, but I can't seem to figure it out. I have also tried to compile with java7, I am not sure if it actually compiled with it with the method I tried.
You shoul add Maven support to your project, because it is the easiest way to manage all the dependencies. To do that you just need to select your project folder in IntelliJ from the Project Toolbar and select "Add Framework support" and then scroll down until you see "Maven".
Once you add Maven support to your project you just need to Enable Auto-imports, IntelliJ itself will display you a menu to select if you want to Enable them or not, you have to select Yes.
Finally, you need to add this block to the new file created in your project folder called pom.xml, just before the project block closes (< /project>):
Once you do that, now you can import and use the JSOUP packages in your project. If you want to add more libraries, you can check out: https://mvnrepository.com/ and select the desired version of the library you want to install and copy&paste the dependency block on your Maven file.
As a tip, I highly recommend you to use a dependency manager (like Maven f.e.) for your projects and always add it once you create the project.
Hope it helps!