I got a java program that's used to parse a url, so i used jsoup to import the libs and i use classpath to point it
but i can't run a java program here, i compiled it, the class file is formed but it says " Could not find or load main class cool "
My program is given below
PGM NAME IS : cool.java
I compiled it using this command : javac -cp jsoup-1.8.3.jar cool.java
It compiles fine
But
when i tried to run this with the below command
"java -cp jsoup-1.8.3.jar cool"
it says the error "Could not find or load main class cool"
My program is given below
package com.mkyong;
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class cool {
public static void main(String[] args) {
Document doc;
try {
// need http protocol
doc = Jsoup.connect("http://google.com").get();
// get page title
String title = doc.title();
System.out.println("title : " + title);
// get all links
Elements links = doc.select("a[href]");
for (Element link : links) {
// get the value from href attribute
System.out.println("\nlink : " + link.attr("href"));
System.out.println("text : " + link.text());
}
} catch (IOException e) {
e.printStackTrace();
}
} }
I'm using ubuntu
No comments:
Post a Comment