简体   繁体   中英

java.lang.NoClassDefFoundError: org.apache.http.client.CredentialsProvider error with HTMLUnit

I am getting the java.lang.NoClassDefFoundError:org.apache.http.client.CredentialsProvider error even after importing the Web client jar files.

Please find the screenshot below.

在此处输入图片说明

Can any one help me where I am going wrong.

You have to add the httpclient.jar from apache to your classpath. You can download it here

Most of the time, NoClassDefFoundError happen when there is missing dependencies to your project. Note that there is other possibilities...

For more information on NoClassDefFoundError you might want to check this thread

Why am I getting a NoClassDefFoundError in Java?

In your case, as @Jens already mentionned, we can see in your referenced libraries that you are missing httpclient.jar

See the http components of Apache download page.

java.lang.NoClassDefFoundError:org.apache.http.client.CredentialsProvider error indicates that httpclient-4.0.3.jar file is mission in your class path.

Configure it in your class path Right click project -> Build Path -> Configure Build Path -> Libraries -> Add Excernal Jars -> select jar file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM