HtmlUnit으로 첫 번째 예제 프로그램을 설정하려고합니다.HtmlUnit 첫 번째 단계
javac -cp lib/htmlunit-2.9.jar test.java
을하지만 난 시험을 간부 인하려고 할 때이 문제가 어디
java -cp lib/htmlunit-2.9.jar test
Exception in thread "main" java.lang.NoClassDefFoundError: test Caused by: java.lang.ClassNotFoundException: test at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) Could not find the main class: test. Program will exit.
이다 얻을 :
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.WebClient;
public class test {
public static void main(String[] args) throws Exception {
WebClient client = new WebClient();
HtmlPage currentPage = client.getPage("http://www.oddsportal.com/matches/soccer");
client.waitForBackgroundJavaScript(10000);
String textSource = currentPage.asXml();
System.out.println(textSource);
}
}
다음 내가 컴파일 :이 코드는? 다른 패키지가 부족합니까?
나는 여러 가지 방법으로 시도하고이 일을하지 않습니다. – emanuele
좋아, 주변을 둘러 본 후에이 문제로 인해 문제가 해결되지 않은 이유를 알아 냈습니다. 이것은 htmlunit에 하나 이상의 항아리가 있기 때문입니다. 따라서 실제로 경로를 모두 나열하거나 경로에 와일드 카드를 사용해야합니다. –