Compiled Java JDBC MySQL Class Not Found [message #1096740] |
Wed, 28 August 2013 16:12  |
Eclipse User |
|
|
|
Hello,
I'm a new Java programmer and I'm working on getting a Java app to communicate with a MySQL database. I've downloaded the connector file and added it to my build path in Eclipse, and the code runs as expected in that environment.
When I create a jar and try to execute it however, I get the class not found exception. I've tried various configurations for deploying the connector with the jar, and the classpath is set and referenced in the build path to the same file. No matter how I configure the file layout, I just can't get the class to be recognized. I've been on Google for the past six hours researching this and I can't find an example I've not tried that has yielded results. I'm on a windows 7 64 bit machine. If there is any other information that would be useful to figuring this out I'd be glad to share it.
If anyone has advice on how to resolve this problem I'd really appreciate it. If there's a way to do this without using the connector, for example, that would be an option. I just need to make this work in a compiled state. Thanks in advance for your help.
Regards,
Dave
|
|
|
|
Re: Compiled Java JDBC MySQL Class Not Found [message #1096764 is a reply to message #1096741] |
Wed, 28 August 2013 16:54  |
Eclipse User |
|
|
|
I got the answer. It took a while, but with some experimentation I was able to get the thing working.
What I had to do was to edit the MANIFEST.MF file to include a Class-Path option. This was not automatically added by Eclipse, although the MANIFEST.MF itself was. The file is located in the META-INF folder in the jar I wished to execute. I opened the jar using 7-zip, then copied out the MANIFEST.MF file and did some simple text editing.
In the file I saw an entry for Main-Class, which I left alone. I tried adding the entire Windows path to the mysql connector jar but that didn't help. What did help was to add just the name of the jar, in my case mysql-connector-java-5.1.25-bin.jar. Then I included that file in the same folder as the .jar I wished to execute. Once I did that the code ran fine.
Dave
[Updated on: Wed, 28 August 2013 16:55] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04142 seconds