0

My application uses MySQL JDBC,I am trying to export JAR file using eclipse.

My question is how to include the MySQL driver so the JAR file can connect to server?

hamid
  • 2,033
  • 4
  • 22
  • 42

3 Answers3

3

You should not include the MySQL driver in your jar. The driver is a separate jar, so you need to add it to your classpath when running your code.

0

If you are trying to create a single jar with all the dependencies, use either OneJar or UberJar to accomplish this.

If you are using ant, there is a simple ant task to do it and it supports to specify the main class and also the classpath in metainf

<jar id="files" jarfile="single.jar">
    <zipfileset src="deped1.jar" includes="**/*.java **/*.class"/>
    <zipfileset src="depend2.jar" includes="**/*.java **/*.class"/>
</jar>
Teja Kantamneni
  • 17,402
  • 12
  • 56
  • 86
0

Here is how to do that with Eclipse: How to create a jar with external libraries included in Eclipse?

Or you may use a tool like OneJar, http://one-jar.sourceforge.net/, to create a single runnable JAR file

Community
  • 1
  • 1
Greg Temkin
  • 76
  • 1
  • 3