maven build error: package org.apache.http does not exist

Go To


I am attempting to send a simple HTTP post from a java program (for deploying on Heroku). I started with the demo project here. Using mvn package builds the project successfully.

I then added my own additional file with a few lines of code, added it to the pom.xml, and still built fine.

Then I tried to add the HTTP code from this example (minus the package line), which uses the Apache HttpClient library.

Using mvn package results in the following error:

package org.apache.http does not exist 

After searching for solutions I tried including a dependency in the pom.xml:


My understanding was that this should force a download of the necessary package but no download was shown on the next compile (just the same error), and the package is not visible in my user .m2\repository\ folder.

I tried inserting this dependency at different points in my pom.xml without success.

Why is the apache library not being downloaded? Please note that I am new to maven.

2016-07-04 14:43
by Andrew
org.http.apache.http isn't the correct package name. It is org.apache.http - Tunaki 2016-07-04 14:50


Here is the pom.xml that you should have if indeed you need to depend on httpclient.

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">





Now if you put your Java sources in src/main/java, where src and pom.xml are in the same directory, Maven should resolve the dependency from your local repository, and download it, should it not already be there. Your local repository is defined in the conf/settings.xml in your Maven installation directory.

2016-07-04 15:05
by Arthur Noseda
This solved it, thank you! Thought I had tried the dependencies in that position in the pom.xml but obviously not.. - Andrew 2016-07-06 13:00