所以我正在寫一個代碼,我從一個職位在這裏,它使用jsoup ..我也使用MACBOOK專業版10.11.3和我的Java是最新的。jsoup未安裝在macbook pro上?類測試編譯錯誤jsoup
的代碼是
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());
}
}
}
我遇到的問題是,我得到的編譯錯誤:
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
所以他這樣說,我下載jsoup-1.10.1.jar但我不知道我是否應該把它放在桌面上或放到一個文件夾中?或者以某種方式打開它?我該怎麼辦?非常感謝!
編輯:這是Jsoup,而不是我的代碼中的特定問題,因爲所有的錯誤指向jsoup這顯然不是我的java庫
可能重複[什麼是「無法找到符號」編譯錯誤是什麼意思?](http://stackoverflow.com/questions/25706216/what-does-a-cannot-find-symbol-compilation-error-mean ) –
不是,這是jsoup特定的,我的java工作正常,它只是這個庫( – JanCamila
)請閱讀上面的鏈接,這意味着你的jsoup jar不可用在classpath中! –