Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Connector/J Trouble(problems getting jar file recognized by compiled output)
Connector/J Trouble [message #1096662] Wed, 28 August 2013 17:44 Go to next message
David Spaar is currently offline David SpaarFriend
Messages: 7
Registered: August 2013
Junior Member
Hello,

I've been working on a simple bit of java code that will read in an XML file containing database information and then connect to the database and run SQL code. I can run it fine in Eclipse, it works as expected. When I export it to a JAR file I find that the code throws a ClassNotFound exception when trying to create a database connection. I've added the mysql-connector-java-5.1.25-bin.jar file I'm using to the CLASSPATH on the server on which I'm trying to run it, as well as including the file in a lib folder and in the build path of the compiled jar.

I'm a new Java programmer, so I could be doing any number of things wrong. Any advice you have would be greatly appreciated. Thanks!

Regards,
Dave
Re: Connector/J Trouble [message #1096767 is a reply to message #1096662] Wed, 28 August 2013 20:56 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
Previous Topic:Compiled Java JDBC MySQL Class Not Found
Next Topic:Problem with Plugins
Goto Forum:
  


Current Time: Tue Apr 16 07:23:39 GMT 2024

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

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

Back to the top