title: How can I specify dependencies in the manifest file and then to include it into my .jar file?
body: <p>I generated .class files by the following command:</p>
  
  <pre><code>javac -cp \directoryName\external.jar myPackageDirectory\First.java myPackageDirectory\Second.java
  </code></pre>
  
  <p>I needed to use <code>-cp</code> during compilation and name of .jar file of an "external" library (external.jar) to be able to use this library from my code.</p>
  
  <hr>
  
  <p>Using my .class files I have generated my .jar file in the following way:</p>
  
  <pre><code>jar cfm app.jar manifest.txt myPackageDirectory\*.class
  </code></pre>
  
  <p><code>manifest.txt</code> contains just one line:</p>
  
  <pre><code>Main-Class: myPackageName.First
  </code></pre>
  
  <hr>
  
  <p><strong>My problem is that I am not sure that I will be able to run my .jar file on other computers.</strong> I think so because during the compilation I specified the location of the .jar file of the external library. So, my .class files (included into the .jar file will try to find the .jar file of the external library in a specific directory and there is no guaranty that that the .jar file of the external library will be in the same directory as on the my computer.</p>
  
  <hr>
  
  <p>I heard that the above problem can be solved by a </p>
  
  <blockquote>
    <p>usage of a MANIFEST file that I
    include in my own jar, and which will
    list dependency locations</p>
  </blockquote>
  
  <p>but I do not understand how it works. I do need to specify location of the "external.jar" at the compilation stage (otherwise the compiler complains).</p>