So I'm writting a code I got from a post here and it uses jsoup.. I'm also USING A MACBOOK PRO version 10.11.3 and my java is up to date.
The code is
package com.stackoverflow.q2835505;
import org.jsoup.*;
import org.jsoup.nodes.*;
import org.jsoup.select.*;
public class Test {
public static void main(String[] args) throws Exception {
String url = "http://stackoverflow.com/questions/2835505";
Document document = Jsoup.connect(url).get();
String question = document.select("#question .post-text").text();
System.out.println("Question: " + question);
Elements answerers = document.select("#answers .user-details a");
for (Element answerer : answerers) {
System.out.println("Answerer: " + answerer.text());
}
}
}
THE PROBLEM I'm having is that I get the compile errors:
Jack-MacBook-Pro:desktop iModelEx$ javac Test.java
Test.java:3: error: package org.jsoup does not exist
import org.jsoup.*;
^
Test.java:4: error: package org.jsoup.nodes does not exist
import org.jsoup.nodes.*;
^
Test.java:5: error: package org.jsoup.select does not exist
import org.jsoup.select.*;
^
Test.java:11: error: cannot find symbol
Document document = Jsoup.connect(url).get();
^
symbol: class Document
location: class Test
Test.java:11: error: cannot find symbol
Document document = Jsoup.connect(url).get();
^
symbol: variable Jsoup
location: class Test
Test.java:16: error: cannot find symbol
Elements answerers = document.select("#answers .user-details a");
^
symbol: class Elements
location: class Test
Test.java:17: error: cannot find symbol
for (Element answerer : answerers) {
^
symbol: class Element
location: class Test
7 errors
So that being said, I downloaded jsoup-1.10.1.jar but I don't know if I should leave it on the desktop or put it into a folder? Or open it somehow? What should I do? Thanks a lot!
EDIT: This is a specific problem with Jsoup and not my code, since all the errors point to jsoup files which apparently aren't implemented properly in my java library