I am trying to create a jar file that is “self contained” concerning the libraries it needs.
Therefore, I created the following ant file:
<project name="srv" default="prod">
<target name="prod">
<jar destfile="build/ServerApplication.jar" basedir="bin/">
<restrict>
<name name="**/*.class"/>
<archives>
<zips>
<fileset dir="lib/" includes="**/*.jar"/>
</zips>
</archives>
</restrict>
<manifest>
<attribute name="Class-Path" value="." />
<attribute name="Main-Class" value="my.package.ServerApplication" />
</manifest>
</jar>
</target>
</project>
But, when I try to launch the application using
> java -jar ServerApplication.jar
I get an error
No suitable driver found for jdbc:mysql://localhost/db?user=root&password=
I reckon this is because the com.mysql.jdbc package inside the jar can’t be found. Why is this? When I set the Class-Path to ., shouldn’t the jar be able to find all classes inside that jar?
I opened the jar in a decompiler, and all the classes are where they need to be, see here:

What is going wrong here? My MANIFEST looks like this:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.7.0_07-b10 (Oracle Corporation)
Main-Class: my.package.ServerApplication
Class-Path: .
You must explicitly write the names of the jars if you want them included separated by spaces. Otherwise I would recommend simply launching your jar and providing the class path as a parameter manually:
See here for more information.