java http不存在_java – Apache httpclient不存在.错误

嗨,我一直在收到错误

test.java:15: package org.apache.commons.httpclient does not exist

import org.apache.commons.httpclient.Cookie;

^

test.java:16: package org.apache.commons.httpclient does not exist

import org.apache.commons.httpclient.HttpState;

^

test.java:17: package org.apache.commons.httpclient does not exist

import org.apache.commons.httpclient.HttpClient;

^

test.java:18: package org.apache.commons.httpclient.methods does not exist

import org.apache.commons.httpclient.methods.GetMethod;

^

test.java:22: cannot find symbol

symbol : class HttpClient

location: class test

HttpClient client = new HttpClient();

^

test.java:22: cannot find symbol

symbol : class HttpClient

location: class test

HttpClient client = new HttpClient();

^

test.java:26: cannot find symbol

symbol : class GetMethod

location: class test

GetMethod method = new GetMethod("https://online.investools.com/authentication/auth.iedu");

^

test.java:26: cannot find symbol

symbol : class GetMethod

location: class test

GetMethod method = new GetMethod("https://online.investools.com/authentication/auth.iedu");

^

test.java:29: cannot find symbol

symbol : class Cookie

location: class test

Cookie[] cookies = client.getState().getCookies();

^

test.java:31: cannot find symbol

symbol : class Cookie

location: class test

Cookie cookie = cookies[i];

^

10 errors

编译我用过

javac -cp ;./httpclient-4.2.jar;jsoup-1.6.3.jar test.java

这是代码

import org.jsoup.Jsoup;

import org.jsoup.nodes.Document;

import org.jsoup.nodes.Element;

import org.jsoup.select.Elements;

import org.apache.commons.httpclient.Cookie;

import org.apache.commons.httpclient.HttpState;

import org.apache.commons.httpclient.HttpClient;

import org.apache.commons.httpclient.methods.GetMethod;

public class test{

public static void main (String []args)throws IOException{

HttpClient client = new HttpClient();

client.getParams().setParameter("username", "SomeUSER");

client.getParams().setParameter("password", "GF@QT#$WE");

GetMethod method = new GetMethod("https://online.investools.com/authentication/auth.iedu");

try{

client.executeMethod(method);

Cookie[] cookies = client.getState().getCookies();

for (int i = 0; i < cookies.length; i++) {

Cookie cookie = cookies[i];

System.err.println(

"Cookie: " + cookie.getName() +

", Value: " + cookie.getValue() +

", IsPersistent?: " + cookie.isPersistent() +

", Expiry Date: " + cookie.getExpiryDate() +

", Comment: " + cookie.getComment());

}

client.executeMethod(method);

}

catch(Exception e) {

System.err.println(e);

}

finally {

method.releaseConnection();

}

我很困惑,不知道我做错了什么.我认为它很简单,但我已经检查过几次并且它存在并且jsoup编译得很好.

谢谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值