creating executable jar, class not found on dependancy
I have my application ready for it's first release but I'm experiencing grief trying to get it to include another jar file it depends on.
The application uses the mysql connector so I need to include the mysql.xxx.jar
I'm using the Eclipse IDE. When I run the program from withing the IDE everything works, but when I export it to a jar the UI does come up but as soon as I do something that requires the database connection I get a ClassNotFoundException for the mysql driver.
How do I create the executable jar and include the mysql connector?
I'm not familiar w. eclipse, but I isn't there a wisard/setup for the jar export where
you can specify the required jars/libraries, or do you have to manually edit
the manifest file ?
Last edited by sjalle; 04-04-2005 at 03:56 AM.
It has an export wizard especially for it, that unfortunately doesn't make it that obvious how to include it. I've specified libraries to include in the projects properties, which one would expect would be picked up in the export process. I do have the option to give it a previously created manifest file.
I've never seen a manifest file before though.
Well, as I run the wizard in JBuilder I have the options to include more or less of the
classes I use, sometimes it's easier to just specify all classes, but that results
in quite large jars. I can't imagine that a jar builder wizard for Exclipse would be
so much more different.
Nevertheless, - the required libraries etc. for the project does not automatically
equal the requirements of the executable jar.
I think it's unbelievable -
I have a lib dir in my project where I've put the jar and when I export, it lets me tick the lib folder but doesn't display the file - what the?
I'm sure they had a good reason to put the feature somewhere else, assuming they have, but I have to say, while I'm *****ing, it's not easy to find where they put it.
Maybe the best is to leave the Eclipse wonderland and lookup the sun java doc
on jars and manifests and just do a jar build from the dos prompt.
Ok, I'm trying to make this jar from the command line now.
I can create the executable jar and it all works fine but... only when the external jar is on the classpath somewhere.
So, just to reiterate, I'm trying to include the external jar within my jar so there's no installation process. Is there something I can do to my manifest to tell it to use the external.jar from inside my new jar?
Here's my manifest
I compile it from the command line using
jar cvfm dbi.jar mymanifest.txt dbImportX
what you want to achieve is quite possible, so I think you should look up the sun javadoc on the web for manifests.
But check this out, they claim to hand out a free java2exe builder...
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL