Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to include *....*.jar file

 
Chris Dancy
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've searched these forums and i've got nothing. So here it goes. Trying to connect to mysql using the proper drivers. Now i know i can add the jar file to the classpath, but is there a way to include the jar file within the source code, and simply use it from there, so as to always have it with the program?

sincerely,
Chris Dancy
 
Chris Dancy
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is of course for an executable jar file. Just to clear things up.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you mean by "include it with the source code", because the source code won't be part of the application once it's built.

You can either distribute the library jar together with the application jar, and have the application jar file manifest refer to the library in the Class-Path attribute.

Or you could re-package them into a single jar file, thus side-stepping any classpath issues.
[ July 28, 2007: Message edited by: Ulf Dittmer ]
 
Chris Dancy
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes thats what i was wondering. So if i go to jar it all up and say the mysql.jar file is in a directory mysqlConnector/ and all files are in directory Sample/ would I create the manifest this way

Manifest-Version: 1.0
Main-Class: Sample/Main
Class-Path: Sample/mysqlConnector/mysql.jar
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think more like this, assuming that the main jar file is in the Sample directory, and mysqlConnector is a subdirectory of that:

Main-Class is strictly a class name, not a directory designation.
 
Chris Dancy
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yea this works. Thanks for the help guys. Its very much appreciated.

sincerely,
Chris Dancy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic