title: Java Sqlite Gradle
body: <p>I'm pretty new to gradle and java at all..</p>
  
  <p>I have a project which uses sqlite and it runs fine through intellij idea but I can't run it from the terminal, it throws an exception:</p>
  
  <pre><code>java.lang.ClassNotFoundException: org.sqlite.JDBC
  </code></pre>
  
  <p>I've tried to get process which intellij idea spawns when it runs the project:</p>
  
  <pre><code>/usr/lib/jvm/java-7-openjdk-amd64/bin/java -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=42986 -Dfile.encoding=UTF-8 -cp /home/user/my_project/target/classes/main:/home/user/my_project/target/resources/main:/home/user/.gradle/caches/modules-2/files-2.1/org.xerial/sqlite-jdbc/3.7.2/7a3d67f00508d3881650579f7f228c61bfc1b196/sqlite-jdbc-3.7.2.jar Main
  </code></pre>
  
  <p>As I see here idea specifies classpath which is the solution but how can I run my .jar file of the project without specifying classpath? I mean can <code>gradle</code> generate manifest automatically (because it retrieves sqlite-jdbc from maven <code>org.xerial</code> repository successfully) and put valid classpath there?
  I want to run it successffully from the terminal.</p>
  
  <p>UPD: I can't it run from the terminal only by <code>gradle run</code> command but I can't run the project by <code>java -jar myproject.jar</code>.</p>
  
  <p>Here is my <code>build.gradle</code>:</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'maven'
  apply plugin: 'idea'
  apply plugin: 'application'
  
  group = 'myproject'
  version = '0.3'
  
  description = """my project description"""
  
  buildDir = "target"
  
  mainClassName = "Main"
  
  repositories {
       maven { url "http://repo.maven.apache.org/maven2" }
  }
  
  dependencies {
      testCompile group: 'junit', name: 'junit', version:'3.8.1'
      compile 'org.xerial:sqlite-jdbc:3.7.2'
  }
  
  
  jar {
      manifest.attributes("Main-Class": "Main")
  }
  
  /* Overwriting distribution tasks: */
  task distZip(type:Zip, overwrite:true) {
      archiveName = "$project.name-$version" + '.zip'
      from "target/libs"
  }
  
  task distTar(type:Tar, overwrite:true) {
      archiveName = "$project.name-$version" + '.tar'
      from "target/libs"
  }
  </code></pre>
  
  <p>Java source code which throws an exception:</p>
  
  <pre><code>try {
      Class.forName("org.sqlite.JDBC");
  
      this.connection = DriverManager.getConnection(databaseName);
  } catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>