Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JAR files and manifest: Class-Path

Reply
Thread Tools

JAR files and manifest: Class-Path

 
 
Karsten Wutzke
Guest
Posts: n/a
 
      01-06-2004
Hi!

I have a base dir, where the application JAR file resides. In this base
dir, there's also a lib dir, nothing special really. In this lib dir are
some user look and feel JAR files, which are supposed to be loaded when
the application is started via the JAR file.

Is there any way to use the Class-Path entry in the manifest, so that it
scans that ./lib directory and loads all the JARs in there, *without
knowing up-front, what these files are*?

I tried

Class-Path: ./lib
Class-Path: ./lib/
Class-Path: ./lib/*
Class-Path: ./lib/*.jar

but none of them work.

Maybe there's some other way, which I don't know of. I simply don't want
to explicitly deploy the JAR's (versions, size etc.).

Anyway, how do I do it?

Karsten


 
Reply With Quote
 
 
 
 
Manish Hatwalne
Guest
Posts: n/a
 
      01-06-2004
Have a look at this and see if it is helpful -
http://java.sun.com/developer/Books/.../manifest.html

Try
Class-Path: lib/

Should work.

HTH,
- Manish


"Karsten Wutzke" <kwutzke-> wrote in message
news:bteng6$rri$02$...
> Hi!
>
> I have a base dir, where the application JAR file resides. In this base
> dir, there's also a lib dir, nothing special really. In this lib dir are
> some user look and feel JAR files, which are supposed to be loaded when
> the application is started via the JAR file.
>
> Is there any way to use the Class-Path entry in the manifest, so that it
> scans that ./lib directory and loads all the JARs in there, *without
> knowing up-front, what these files are*?
>
> I tried
>
> Class-Path: ./lib
> Class-Path: ./lib/
> Class-Path: ./lib/*
> Class-Path: ./lib/*.jar
>
> but none of them work.
>
> Maybe there's some other way, which I don't know of. I simply don't want
> to explicitly deploy the JAR's (versions, size etc.).
>
> Anyway, how do I do it?
>
> Karsten
>
>



 
Reply With Quote
 
 
 
 
Karsten Wutzke
Guest
Posts: n/a
 
      01-06-2004
I had a look at this document before. Anyway, lib/ *doesn't* work.

Any other ideas? I need some kind of regular expression to include *all*
JAR's in a certain path.

Karsten


Manish Hatwalne wrote:

> Have a look at this and see if it is helpful -
> http://java.sun.com/developer/Books/.../manifest.html
>
> Try
> Class-Path: lib/
>
> Should work.
>
> HTH,
> - Manish
>
>
> "Karsten Wutzke" <kwutzke-> wrote in message
> news:bteng6$rri$02$...
>
>>Hi!
>>
>>I have a base dir, where the application JAR file resides. In this base

snip

 
Reply With Quote
 
Dave Glasser
Guest
Posts: n/a
 
      01-07-2004
Karsten Wutzke <kwutzke-> wrote on Tue, 06 Jan
2004 17:24:33 +0100 in comp.lang.java.programmer:

>Hi!
>
>I have a base dir, where the application JAR file resides. In this base
>dir, there's also a lib dir, nothing special really. In this lib dir are
>some user look and feel JAR files, which are supposed to be loaded when
>the application is started via the JAR file.
>
>Is there any way to use the Class-Path entry in the manifest, so that it
>scans that ./lib directory and loads all the JARs in there, *without
>knowing up-front, what these files are*?
>
>I tried
>
>Class-Path: ./lib
>Class-Path: ./lib/
>Class-Path: ./lib/*
>Class-Path: ./lib/*.jar
>
>but none of them work.
>
>Maybe there's some other way, which I don't know of. I simply don't want
>to explicitly deploy the JAR's (versions, size etc.).
>
>Anyway, how do I do it?


Check out my app QueryForm. It does exactly what you are trying to do,
but it doesn't use the manifest Class-Path mechanism. The homepage is
http://qform.sourceforge.net.

It uses a custom classloader to load all of the .jar and .zip files in
a directory called "drivers" which is below the directory where the
application jar file is. These jar files can contain JDBC drivers or
third-party look-and-feels. You load them into the classloader at
runtime like this:

ClassLoader loader = ExtensionClassLoader.getSingleton();
loader.addArchivesInDirectory(new File(pathToLibDirectory));

(See the code in org/glasser/qform/QForm.java for more details on how
it discovers the path to the lib (drivers) directory at runtime.)

Then, when you need a new look and feel, provided you have the class
name, you can do:

ClassLoader loader = ExtensionClassLoader.getSingleton();
Class lafClass = loader.loadClass(lafClassName);
LookAndFeel laf = (LookAndFeel) lafClass.newInstance();
UIManager.setLookAndFeel(laf);
UIManager.getDefaults().put("ClassLoader", lafClassgetClassLoader());
UIManager.getLookAndFeelDefaults().put("ClassLoade r",
lafClass.getClassLoader());
SwingUtilities.updateComponentTreeUI(eachFrame);

The source for ExtensionClassLoader is in
org/glasser/util/ExtensionClassLoader.java. It's released under an
Apache-style license, so you can use it in a closed-source,
proprietary program if you want.


--
Check out QueryForm, a free, open source, Java/Swing-based
front end for relational databases.

http://qform.sourceforge.net
 
Reply With Quote
 
Thomas Schodt
Guest
Posts: n/a
 
      01-07-2004
Karsten Wutzke wrote:

> Is there any way to use the Class-Path entry in the manifest, so that it
> scans that ./lib directory and loads all the JARs in there, *without
> knowing up-front, what these files are*?


I doubt it.

> Maybe there's some other way, which I don't know of. I simply don't want
> to explicitly deploy the JAR's (versions, size etc.).


Can be done in a shell script.

Code:
#!/bin/sh

CP=.
for I in ./lib/*.jar
do
CP=$CP:$I
done
echo "java -classpath \"$CP\" MyClass"
 
Reply With Quote
 
hiwa
Guest
Posts: n/a
 
      01-13-2004
Karsten Wutzke <kwutzke-> wrote in message news:<bteng6$rri$02$>...
> Hi!
>
> I have a base dir, where the application JAR file resides. In this base
> dir, there's also a lib dir, nothing special really. In this lib dir are
> some user look and feel JAR files, which are supposed to be loaded when
> the application is started via the JAR file.
>
> Is there any way to use the Class-Path entry in the manifest, so that it
> scans that ./lib directory and loads all the JARs in there, *without
> knowing up-front, what these files are*?
>
> I tried
>
> Class-Path: ./lib
> Class-Path: ./lib/
> Class-Path: ./lib/*
> Class-Path: ./lib/*.jar
>
> but none of them work.
>
> Maybe there's some other way, which I don't know of. I simply don't want
> to explicitly deploy the JAR's (versions, size etc.).
>
> Anyway, how do I do it?
>
> Karsten


Accoding to the tutorial at Sun's site, answer is:

Class-Pass: lib/aaa.jar lib/bbb.jar lib/xyz.jar

Point is: (1)use relative path
(2)delimiter here is space
 
Reply With Quote
 
Ilya Ilya is offline
Junior Member
Join Date: Jun 2009
Posts: 1
 
      06-10-2009
Maybe it would be useful for someone

I have the same problem and i solved it so

app.jar - my application
lib/ - directory for extensions (jar files)

suppose app.Main - main class

to startup application you can invoke

java -cp "app.jar:lib/*" app.Main

--------------------------------------
mail.ilja_at_yahoo.com
 

Last edited by Ilya; 06-10-2009 at 05:12 PM..
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
java -cp a.jar -jar b.jar => Works on Windows, not on Debian cyberco Java 4 02-14-2006 06:27 AM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters XML 0 01-05-2005 10:59 PM
Jar files in Jar files Eric McIntyre Java 1 05-24-2004 07:24 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57