• 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

Packaging JavaMail JARs into Application

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am developing an application which uses the JavaMail API. I have found JavaMail very easy to use, but, while packaging my application, I have run into a problem. I wish to package my application into a single self-extracting jar file. However, I also want to include the JavaMail jars (mail.jar, activation.jar, etc) in my application so that my clients don't have to put the JavaMail jars into their /lib/ext folders. I have not been able to successfully package my application into one self-extracting jar file without getting a NoClassDefFoundError at runtime.

Could anyone please advise me on how to package the JavaMail jar files into my application? I have done some searching and can only come up with this bug report.

Regards,

TBA
[ May 25, 2006: Message edited by: Tomas Anderson ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The bug report sounds to me as if it is about a different problem.

Generally, you should have no problems creating just one jar file out of many. However, you may run into problems if people already have one or more of the jars in their extension directory. You could easily get a version mismatch in that case. Might that be the case here?
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The simple and straightforward way to do it is this:

1. Put a line in your jar's manifest that looks like this:2. Install your jar file, mail.jar, and activation.jar in the same directory.
 
Tomas Anderson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Class-Path: mail.jar activation.jar



That looks very helpful; would it add to the classpath or overwrite it?


Install your jar file, mail.jar, and activation.jar in the same directory.


Can I put mail.jar and activation.jar inside my jar file?

thanks,
TBA

[EDIT] PS: I highly doubt a version mismatch is the problem. [/EDIT]
[ May 27, 2006: Message edited by: Tomas Anderson ]
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tomas Anderson:
That looks very helpful; would it add to the classpath or overwrite it?


Neither. If you are running your executable jar via "java -jar something.jar" it would BE the classpath, along with the executable jar itself.

Can I put mail.jar and activation.jar inside my jar file?

Not if you expect the manifest's Class-Path entry to be able to find them.
 
Tomas Anderson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help.

I was hoping to get my whole program (+mailAPI) into one jar file, but 1 directory should suffice.

Regards,
TBA
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic