title: java.lang.ClassNotFoundException: org.jsoup.nodes.Document using Maven
body: <p>I'm using maven to manage my project.</p>
  
  <p>This is my main file:</p>
  
  <pre><code>package com.sample;
  
  import org.jsoup.Jsoup;
  import org.jsoup.nodes.Document;
  
  /**
   * Hello world!
   *
   */
  public class App {
      public static void main(String[] args )
      {
          try
          {
  
          /*  String html = "&lt;html&gt;&lt;head&gt;&lt;title&gt;First parse&lt;/title&gt;&lt;/head&gt;"
                        + "&lt;body&gt;&lt;p&gt;Parsed HTML into a doc.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;";
                      Document doc = Jsoup.parse(html);*/
              Document doc = Jsoup.connect("http://www.javatpoint.com").get();  
              String title = doc.title();  
              System.out.println("title is: " + title);  
          }
          catch (Exception e)
          {
              System.out.println(e);
          }
      }
  }
  </code></pre>
  
  <p>This is my pom.xml:</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.sample&lt;/groupId&gt;
      &lt;artifactId&gt;sample-pc&lt;/artifactId&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;sample-pc&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.jsoup&lt;/groupId&gt;
              &lt;artifactId&gt;jsoup&lt;/artifactId&gt;
              &lt;version&gt;1.8.3&lt;/version&gt;
                      &lt;scope&gt;compile&lt;/scope&gt;
  
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
          &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;archive&gt;
                          &lt;manifest&gt;
                              &lt;mainClass&gt;com.sample.App&lt;/mainClass&gt;
                          &lt;/manifest&gt;
                      &lt;/archive&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>When I run the following commands:</p>
  
  <pre><code>mvn clean package
  java -jar target/sample-pc-1.0-SNAPSHOT.jar 
  </code></pre>
  
  <p>I get the following errors:</p>
  
  <blockquote>
    <p>Error: A JNI error has occurred, please check your installation and
    try again Exception in thread "main" java.lang.NoClassDefFoundError:
    org/jsoup/nodes/Document  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.jsoup.nodes.Document
      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.</p>
  </blockquote>
  
  <p>However, if I directly run the app from eclipse, it runs without any errors. I am not sure why I cant run it from the command line.</p>
  
  <p>Thanks</p>