Reputation: 3128
I have made use of JDBC in one of my projects and it worked flawlessly in Eclipse. I had to add the ojdbc6.jar
to Java Build Path to the project BTW. (I have also not included any Class.forName
statements in the code since I heard it's optional for JDBC 4 and above)
When I export the project into a jar file, and try to run it, it complains saying "No driver found for JDBC" and so on. I can see that this is because the ojdbc6.jar
is missing from the build path now. Can someone please let me know of a solution?
Thanks!
Upvotes: 0
Views: 631
Reputation: 626
Here is a simple method to export a JAR that uses external jar as libs:
The content in manifest file looks like:
Manifest-Version:1.0
Main-Class:com.enginebai.activity.MyJDBCProgram
Class-Path:lib/ojdbc6.jar lib/some-externam-lib.jar
and make sure to put a blank line under Class-Path, otherwise the JAR won't run. (I have no idea why to put a blank line over there.)
Let's go back to eclipse:
ojdbc6.jar
be in project/lib folder.Upvotes: 1
Reputation: 3128
I have done some research and found a solution that seems to work. I have exported the project into a "Runnable Jar file" instead of just a "jar file". This way, I was actually able to repack Jar files from my Build Path into the new Jar file I am exporting my project to. Simple and clean.
You also might want to look at signed Jar files and any other certificates in your existing jar files in the Build Path. They cannot directly be repacked through the export option.
Upvotes: 0