htmlunit中的classpath问题,总是找不到package# Java - 爪哇娇娃
j*3
1 楼
用的ubuntu12.04 64bit
我把htmlunit那个lib文件都拷贝到lib的目录下,设置了classpath,但是每次complie
都出错。
求助各位,折腾了好久不知道什么问题
Debugging information as follows:
[email protected]:~$ echo $CLASSPATH
/home/jnsong:/home/jnsong/Downloads/htmlunit-2.10/lib
_____________________________________________
[email protected]:~$ javac myClient.java
myClient.java:6: error: package com.gargoylesoftware.htmlunit does not exist
import com.gargoylesoftware.htmlunit.Page;
^
myClient.java:7: error: package com.gargoylesoftware.htmlunit does not exist
import com.gargoylesoftware.htmlunit.WebClient;
^
myClient.java:8: error: package com.gargoylesoftware.htmlunit does not exist
import com.gargoylesoftware.htmlunit.HtmlPage2;
^
myClient.java:13: error: cannot find symbol
WebClient webClient = new WebClient();
^
symbol: class WebClient
location: class myClient
myClient.java:13: error: cannot find symbol
WebClient webClient = new WebClient();
^
symbol: class WebClient
location: class myClient
myClient.java:14: error: cannot find symbol
HtmlPage page = webClient.getPage("http://google.com"); // Pass in URL
^
symbol: class HtmlPage
location: class myClient
6 errors
[email protected]:~$ ^
__________________________________________________________
myclient.java 的程序内容
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.lang.String;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
public class myClient {
public static void main(String[] args) throws Exception {
// Create and initialize WebClient object
WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage("http://google.com"); // Pass in URL
Console.out.println(page.toString());
}
}
谢谢了!
我把htmlunit那个lib文件都拷贝到lib的目录下,设置了classpath,但是每次complie
都出错。
求助各位,折腾了好久不知道什么问题
Debugging information as follows:
[email protected]:~$ echo $CLASSPATH
/home/jnsong:/home/jnsong/Downloads/htmlunit-2.10/lib
_____________________________________________
[email protected]:~$ javac myClient.java
myClient.java:6: error: package com.gargoylesoftware.htmlunit does not exist
import com.gargoylesoftware.htmlunit.Page;
^
myClient.java:7: error: package com.gargoylesoftware.htmlunit does not exist
import com.gargoylesoftware.htmlunit.WebClient;
^
myClient.java:8: error: package com.gargoylesoftware.htmlunit does not exist
import com.gargoylesoftware.htmlunit.HtmlPage2;
^
myClient.java:13: error: cannot find symbol
WebClient webClient = new WebClient();
^
symbol: class WebClient
location: class myClient
myClient.java:13: error: cannot find symbol
WebClient webClient = new WebClient();
^
symbol: class WebClient
location: class myClient
myClient.java:14: error: cannot find symbol
HtmlPage page = webClient.getPage("http://google.com"); // Pass in URL
^
symbol: class HtmlPage
location: class myClient
6 errors
[email protected]:~$ ^
__________________________________________________________
myclient.java 的程序内容
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.lang.String;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
public class myClient {
public static void main(String[] args) throws Exception {
// Create and initialize WebClient object
WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage("http://google.com"); // Pass in URL
Console.out.println(page.toString());
}
}
谢谢了!