When compiling a java file you might face an error of :
error: package org.apache.http does not exist
Just download the Apache HttpComponents , and select the appropriate version . For example the HttpClient 5.0.3
version , or the HttpClient 4.5.13
version …
Extract the version you have selected , in the root of your application , so that you have a lib folder containing some jar files , as follows :
. ├── HttpEx.java └── lib ├── commons-codec-1.11.jar ├── commons-logging-1.2.jar ├── fluent-hc-4.5.13.jar ├── httpclient-4.5.13.jar ├── httpclient-cache-4.5.13.jar ├── httpclient-osgi-4.5.13.jar ├── httpclient-win-4.5.13.jar ├── httpcore-4.4.13.jar ├── httpmime-4.5.13.jar ├── jna-4.5.2.jar └── jna-platform-4.5.2.jar
Compile the desired source file , specifying the lib folder in the class path , as follows :
$ javac -cp '.:./lib/*' HttpEx.java # under macOS or freebsd or linux $ javac -cp '.;.\lib\*' HttpEx.java # under windows