java - 在Netbean中使用unirest发送短信

标签 java android api unirest

我正在尝试使用uni-rest在java中发送短信。我遇到了一些错误。当我输入电话号码时,错误显示为NoClassDefFoundError:org/apache/http/HttpEntity以及一些我认为问题与jar文件有关的错误? 下面是我编写的使用 uni-rest 发送短信的代码,所有库都附加在截图中,并且附加了错误快照。似乎 jar 文件没有添加到项目中。我做错了什么?

public class JavaApplication2 {


    private static ObjectMapper objectMapper = new ObjectMapper();

    public static void main(String[] args) throws UnirestException, IOException {
        Scanner scanIn = new Scanner(System.in);
        System.out.println("Enter your phone number: ");
        String phoneNumber = scanIn.nextLine();
        scanIn.close();
                System.out.printf("entering to http response is ");

    /*HttpResponse<String> response =                       
    Unirest.post("xyz")
    .header("authorization", "abc")
    .header("content-type", "application/json")
    .header("accept", "application/json")
    .body("[{"
                + "'from': 'Example',"
                + "'to': '" +"435456"+ "',"
                + "'body': 'Hello World. This is a test message',"
                + "}]")
          .asString();
      */

          HttpResponse<String> response 
         =Unirest.post("http://xyz")
         .header("authorization", "abc")
         .header("content-type", "application/json")
         .header("accept", "application/json")


     .body({\"from\":\"InfoSMS\",\"to\":\"45465678\",\"text\":\"TestSMS.\"}")
         .asString(
         );



        }
    }

我使用了以下库 enter image description here

我收到以下错误

enter image description here

最佳答案

运行程序时,您需要将所需的 jar(包含 httpEntity 和其他相关类)添加到您的 classpath 中。构建路径用于编译/构建代码,但不用于执行。

关于java - 在Netbean中使用unirest发送短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49507230/

相关文章:

java - sql查询条件java servlet

android - 无法识别 keytool-importkeypair

android - 服务是否与 Activity 一起被杀死

python - 使用 Python 的 odesk API POST 作业

ajax - 使用 API 身份验证和未登录的用户构建 API 驱动的网站

php - 按时移获取数据 - PHP MYSQL

java - 线程新手 : Joining thread one after another with concurrent

java - 如何在java中使用gdata获取访问 token

java - JPA 外键 OneToMany

java - 更新 ListView 不起作用