开发者

How to compile a source file with jsoup.jar in classpath?

开发者 https://www.devze.com 2023-03-26 14:24 出处:网络
I have a problem on executing a compiled file. I compile my Hello.java file as javac -cp \\mypathto\\jsoup.jar Hello.java

I have a problem on executing a compiled file. I compile my Hello.java file as

javac -cp \mypathto\jsoup.jar Hello.java 

I can't execute it after, because I got the "undefined class Jsoup" error. I tried with different ways to add开发者_开发百科 classpath but its still the same. Any idea? The Hello.java

import java.io.File;
import org.jsoup.*;


public class Hello {

    /**
     * @param args
     */
    public static void main(String[] args)throws Exception {
        try {
            File input = new File("prove.xml");

            Document doc = Jsoup.parse(input, "UTF-8");
//Document doc = Jsoup.connect("http://en.wikipedia.org/").get();

            Elements descriptions = doc.select("div.details > p.description");

            for (Element element : descriptions) {
                System.out.println(element.ownText());
                System.out.println("--------------");
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}


Try using some IDE like eclipse,netbeans,IDEA etc. so that it will be easy to run and debug

0

精彩评论

暂无评论...
验证码 换一张
取 消