title: after packaging and running app I get java.lang.ClassNotFoundException: org.apache.hive.jdbc.HiveDriver
body: <p>When I try to run the code in IDEA I don't get this error, but after I package it and try to run the jar with </p>
  
  <pre><code>java -cp app.jar com.hive.connect.controller.RecordController
  </code></pre>
  
  <p>I get this exception.</p>
  
  <pre><code>java.lang.ClassNotFoundException: org.apache.hive.jdbc.HiveDriver
  </code></pre>
  
  <p>My maven</p>
  
  <pre><code>  &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;4.12&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.hive&lt;/groupId&gt;
        &lt;artifactId&gt;hive-jdbc&lt;/artifactId&gt;
        &lt;version&gt;1.1.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;
        &lt;artifactId&gt;hadoop-core&lt;/artifactId&gt;
        &lt;version&gt;1.2.1&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  </code></pre>
  
  <p>My code </p>
  
  <pre><code>public class RecordController {
  private static String driverName = "org.apache.hive.jdbc.HiveDriver";
  
  public static void main(String[] args) throws SQLException, ClassNotFoundException {
      Class.forName(driverName);
      Connection con = DriverManager
                         .getConnection("jdbc:hive2://host:port/db;" +
                                          "principal=principal");
      Statement stmt = con.createStatement();
      String tableName = "evkuzmin_testHiveDriverTable";
      stmt.execute("drop table if exists " + tableName);
      stmt.execute("create table " + tableName + " (key int, value string)");
    }
  }
  </code></pre>
  
  <p>Why does this happen?</p>
  
  <p>EDIT 
  Full error</p>
  
  <pre><code>Exception in thread "main" java.lang.ClassNotFoundException: org.apache.hive.jdbc.HiveDriver
          at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
          at java.lang.Class.forName0(Native Method)
          at java.lang.Class.forName(Class.java:190)
          at com.hive.connect.controller.RecordController.main(RecordController.java:18)
  </code></pre>