• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is of course for an executable jar file. Just to clear things up.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yea this works. Thanks for the help guys. Its very much appreciated.

sincerely,
Chris Dancy
reply
    Bookmark Topic Watch Topic
  • New Topic