I have problems with importing the unirest library. Sample code . I successfully imported the library, but I have problems with the file with the package "com.mashape.unirest.http", it does not have the following files:

import org.apache.http.HttpHost; import org.apache.http.client.HttpClient; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; 

No idea what to do, because I searched for these files via Google and Yandex for about 30 minutes, but I could not find the answer. I can not physically find them. HELP

  • You have connected the library, but have not connected the dependencies. Here they are listed in the documentation. This should all be in the classppath. Are you using an assembly system? - enzo
  • Downloaded the link below by clicking: "Download ZIP". github.com/Mashape/unirest-java/tree/master/src/main/java/com/... enzo, I did not understand the build system, so I do not use it. I'm a newbie. Wial, how to tighten dependencies? Where to write this code and how to run? As I understand it is not java, but xml. But what to do with it? - user210114
  • Imported unirest-java-1.4.9 from the link below: stackoverflow.com/questions/21051991/… The problem is relevant. Help plz - user210115
  • Intellij idea Maven getting started - create a maven project, copy dependencies, update. - Wi-Al
  • Isn't it hc.apache.org ? - Sergey

1 answer 1

Apparently, you just downloaded this library as a jar file, but this library pulls several transitive dependencies (which in turn draw their own).

You can look at them in the section: Compile Dependencies by reference. http://mvnrepository.com/artifact/com.mashape.unirest/unirest-java/1.4.9

And even download, but I do not advise doing this. I advise you to study the maven https://maven.apache.org/

The simplest script (pom.xml) that tightens all dependencies:

 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>id</groupId> <artifactId>artifactId</artifactId> <version>0.1-SNAPSHOT</version> <packaging>jar</packaging> <dependencies> <dependency> <groupId>com.mashape.unirest</groupId> <artifactId>unirest-java</artifactId> <version>1.4.9</version> </dependency> </dependencies> </project>