title: Class not Found for HttpUriRequest
body: <p>I am trying to make a Jar file to be used to connect to a rest service I have written in Node.js. I was following this guide to do so.</p>
  
  <p><a href="https://www.mkyong.com/webservices/jax-rs/restful-java-client-with-apache-httpclient/" rel="nofollow noreferrer">https://www.mkyong.com/webservices/jax-rs/restful-java-client-with-apache-httpclient/</a></p>
  
  <p>After compiling with Maven it gives this error:</p>
  
  <pre><code> Error: A JNI error has occurred, please check your installation and try again
      Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest
          at java.lang.Class.getDeclaredMethods0(Native Method)
          at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
          at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
          at java.lang.Class.getMethod0(Class.java:3018)
          at java.lang.Class.getMethod(Class.java:1784)
          at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
          at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
      Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpUriRequest
          at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  </code></pre>
  
  <p><strong><em>App.java</em></strong></p>
  
  <pre><code>package com.vogella.build.maven.java;
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.net.MalformedURLException;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.entity.StringEntity;
  import org.apache.http.impl.client.DefaultHttpClient;
  
  public class App {
  
      public static void main(String[] args) {
  
        try {
  
          DefaultHttpClient httpClient = new DefaultHttpClient();
          HttpPost postRequest = new HttpPost(
              "http://localhost:3001/getTestData");
  
          HttpResponse response = httpClient.execute(postRequest);
  
          if (response.getStatusLine().getStatusCode() != 201) {
              throw new RuntimeException("Failed : HTTP error code : "
                  + response.getStatusLine().getStatusCode());
          }
  
          BufferedReader br = new BufferedReader(
                          new InputStreamReader((response.getEntity().getContent())));
  
          String output;
          System.out.println("Output from Server .... \n");
          while ((output = br.readLine()) != null) {
              System.out.println(output);
          }
  
          httpClient.getConnectionManager().shutdown();
  
        } catch (MalformedURLException e) {
  
          e.printStackTrace();
  
        } catch (IOException e) {
  
          e.printStackTrace();
  
        }
  
      }
  
  }
  </code></pre>
  
  <p><strong><em>pom.xml</em></strong></p>
  
  <pre><code>&lt;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/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
    &lt;groupId&gt;com.vogella.build.maven.java&lt;/groupId&gt;
    &lt;artifactId&gt;com.vogella.build.maven.java&lt;/artifactId&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
    &lt;name&gt;com.vogella.build.maven.java&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
          &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
          &lt;version&gt;4.1.1&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Would anybody know whats going wrong with this?</p>