title: Create a jar with dependencies from bash
body: <p>First of all I want to say that I do not want to use Maven, Ant, Gradle, any IDE or similar for this task.</p>
  
  <p>I want to make a runnable jar using a bash script. The jar should includes all jar-content from my "libs" folder.</p>
  
  <p>I have started this script and it "almost" works(until the jar creattion):</p>
  
  <pre><code>#!/bin/bash
  
  #Setup
  libs=$(find libs -name "*.jar" -print0 | xargs -0 | sed -e 's/ /:/g')
  tmp2=$(sed -e 's/:/\n ..\//g' &lt;&lt;&lt; $libs)
  tmp2=../$tmp2
  libs=$libs:src
  mkdir tmp
  
  #Compile
  javac -d tmp -classpath "$libs" src/main/PublishData.java
  
  
  #Create manifest
  cd tmp
  echo "Main-Class: main.PublishData" &gt;&gt; m.mf
  echo "Class-Path: $tmp2" &gt;&gt; m.mf
  
  #Build jar
  jar cvfm thejar.jar m.mf *
  </code></pre>
  
  <p>An m.mf example file would look like this:</p>
  
  <pre><code>Main-Class: MyMain
  Class-Path: ../libs/1.jar
   ../libs/2.jar
  </code></pre>
  
  <p>The file structure looks like this:</p>
  
  <pre><code>├── src
  ├── tmp (created by the script, jar cvfm thejar.jar m.mf * is run here)
  ├── libs
  │   ├── jar1
  │   ├── jar2
  </code></pre>
  
  <p>The jar file is created and can be executed but the referenced jars are not found.
  (E.g: <code>Exception in thread "main" java.lang.NoClassDefFoundError: com/mongodb/MongoClient</code>
  ) </p>
  
  <p>It seams to me like the jar program could not find the jars. </p>
  
  <p><strong>How can I successfully "include" my jars from the libs dir?</strong></p>
  
  <hr>
  
  <p>UPDATE:</p>
  
  <p>Every line in the "Class-Path:" section of a manifest file needs to start and end with a white space this caused the class-path to break.</p>