title: Java - Pack referenced libraries into jar file and re-use
body: <p>When I create a new Java project that use third party dependencies such as MySQL-Connector, and export this into a jar file to use in another Java project, how do I avoid having to add (again) the MySQL-Connector library to the new projects build path?</p>
  
  <p>What I would like to achieve is to pack down referenced libraries with the jar file, so when I add it to a new project its dependencies are already met within the jar "container" and I can avoid</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.ClassNotFoundException:
    com.mysql.jdbc.Driver</p>
  </blockquote>
  
  <p><strong>>>Example&lt;&lt;</strong></p>
  
  <p>When working with my SQL database I first need the MySQL-connector library, this of course have the prepared-statements methods, update query and so on. But it doesn't have (as far as I know) for example a method for multiple query updates or updates with an unknown number of ?,?,? arguments etc. So for my own part I have created a SQL manager project that contains a class that contains all the SQL methods I need.</p>
  
  <p>I then import the MySQL-connector -> into the manager project and I would like to export this entire project as a self-contained jar file so when I import the manager jar into a project that needs a database, I don't need to both import the manager jar and the connector, but just the manager that than contains the connector.</p>