Mashape Unirest Java : java.lang.NoClassDefFoundEr

2019-06-08 16:34发布

I'm building an application using Mashape's Unirest library(unirest-java-1.2.6.jar) . I'm getting NoClassDefFoundError during runtime. I tried CommonsWare's method. But it didn't work. Here is the screenshot of Java Build Path. Anything wrong in this screenshot??

enter image description here

2条回答
一纸荒年 Trace。
2楼-- · 2019-06-08 17:07

It's advisable to package everything in one uber jar by using Maven.

Please refer to this post on how to use Unirest in your Java projects.

查看更多
一夜七次
3楼-- · 2019-06-08 17:21

I'm the author of Unirest-Java.

In order to use the library, you need to include the required dependencies into your project:

  • Apache HttpComponents Client
  • Apache HttpComponents AsyncClient
  • Apache HttpComponents Mime
  • JSON library

Using Maven is the preferred method: https://github.com/Mashape/unirest-java#installing

Otherwise the libraries can be manually downloaded from http://hc.apache.org/downloads.cgi and http://www.json.org/java/index.html

But again, I would strongly recommend to use Maven. Also please update the Unirest library to the newest version because 1.2.6 is deprecated now.

查看更多
登录 后发表回答