Including 3rd party libraries within a jar file

F

fritz-bayer

Hello,

how to I include a third party library (in form of a jar file) into my
own jar file? I can't get it working.

I know that in the Manifest file there is an entry called
"Class-Path:", which supposely serves that purpose.

The jar file I have keeps the third party library at
lib/thirdParyLibrary.jar in the jar file.

So a "jar tf myPackedProgram.jar" returns:

META-INF/
META-INF/MANIFEST.MF
mypackage/
mypackage/subpacke/
....
lib/
lib/thirdParyLibrary.jar

The entry in the manifest file is:
Class-Path: lib/thirdParyLibrary.jar
 
C

Chris

how to I include a third party library (in form of a jar file) into my
own jar file? I can't get it working.

Unpack the 3rd party library first, then repack it along with all the class
files in your application.
 
F

fritz-bayer

Hi Chris,

thanks for the reply - that works fine!

Nevertheless I was wondering whether or not you can include third
library jar files without extracting them?
Is that possible at all?

Fritz
 
H

Harish

in the manifest file, u specify the location of the 3rdparty jar in the file
system...
so to get this working, u'll have to create a directory "lib" where u'd kept
ur application jar file.
and then move the 3rd party jar to this dir.
 
F

fritz-bayer

Harish,

above I`m saying that I have created a dir called "lib" whithin which I
keep the 3rd party libraries. I even specified the location using
"Class-Path" but it does not work.
 
F

fritz-bayer

Harish,

above I`m saying that I have created a dir called "lib" whithin which I
keep the 3rd party libraries. I even specified the location using
"Class-Path" but it does not work.

Turth is that this can't be done - you may not include jars withing
jars as libraries.
 
J

Jacob

how to I include a third party library (in form of a jar file) into my
own jar file? I can't get it working.

I know that in the Manifest file there is an entry called
"Class-Path:", which supposely serves that purpose.

You don't bundle jars.

For your development setup, use the -classpath option.

For deployment, the Manifest "Class-Path" applies when
delivered as an applet or through Java Web Start. JWS is
btw the preferred way to deploy java applications.

Otherwise, pass the set of jars to your customer, possibly
with some install and execute script in order to get the
classpath correct.

As already suggested you might unjar 3rd-party jars and
rejar them with your own stuff. I would not recommend
it, as there might be license issues.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top