Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Compiled Java JDBC MySQL Class Not Found(In Eclipse my code runs fine but when exported to jar it fails to find the class)
Compiled Java JDBC MySQL Class Not Found [message #1096740] Wed, 28 August 2013 20:12 Go to next message
David Spaar is currently offline David SpaarFriend
Messages: 7
Registered: August 2013
Junior Member
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 #1096741 is a reply to message #1096740] Wed, 28 August 2013 20:13 Go to previous messageGo to next message
David Spaar is currently offline David SpaarFriend
Messages: 7
Registered: August 2013
Junior Member
Sorry for the duplication, when I checked just before posting this second message I didn't see the first, and thought I'd forgotten to hit the Create Topic button. My bad.
Re: Compiled Java JDBC MySQL Class Not Found [message #1096764 is a reply to message #1096741] Wed, 28 August 2013 20:54 Go to previous message
David Spaar is currently offline David SpaarFriend
Messages: 7
Registered: August 2013
Junior Member
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 20:55]

Report message to a moderator

Previous Topic:how to extract scope information from Eclipse JDT core batch compiler?
Next Topic:Connector/J Trouble
Goto Forum:
  


Current Time: Thu Apr 25 08:30:22 GMT 2024

Powered by FUDForum. Page generated in 0.03734 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top