Including a folder's JAR files in CLASSPATH  
Author Message
Rizwan





PostPosted: 2004-8-31 23:54:00 Top

java-programmer, Including a folder's JAR files in CLASSPATH I have a folder C:\DevPrograms\Hibernate\lib which has 33 JAR files. I want
to include them in my CLASSPATH but not hardcoding the name of the jar
files; instead i want some thing like C:\DevPrograms\Hibernate\lib\*.jar so
that it can pick up all jar. I tried doing it but no success. What other
ways I can do it?
Thanks


 
dhananjay_java





PostPosted: 2004-9-1 15:20:00 Top

java-programmer >> Including a folder's JAR files in CLASSPATH "Rizwan" <email***@***.com> wrote in message news:<qb1Zc.13847$email***@***.com>...
> I have a folder C:\DevPrograms\Hibernate\lib which has 33 JAR files. I want
> to include them in my CLASSPATH but not hardcoding the name of the jar
> files; instead i want some thing like C:\DevPrograms\Hibernate\lib\*.jar so
> that it can pick up all jar. I tried doing it but no success. What other
> ways I can do it?
> Thanks

There are two ways, I believe..
1) put all those jar files in the lib folder of java home directory.
Using this method you need to use the classpath. Java will
automatically detect it. If you are using any Java Extension framework
component then put the jar file in <java_home>/lib/ext directory.

2) The second option is little bit un-reliable but you can use this
with a little sense. Make a single jar file of all those 22 jar files
and include that single jar file in your classpath. But make sure that
the folders of the each jar file must not be same.

Dhananjay Singh)
 
KC Wong





PostPosted: 2004-9-1 17:18:00 Top

java-programmer >> Including a folder's JAR files in CLASSPATH > > I have a folder C:\DevPrograms\Hibernate\lib which has 33 JAR files. I
want
> > to include them in my CLASSPATH but not hardcoding the name of the jar
> > files; instead i want some thing like C:\DevPrograms\Hibernate\lib\*.jar
so
> > that it can pick up all jar. I tried doing it but no success. What other
> > ways I can do it?
> > Thanks
>
> There are two ways, I believe..
> 1) put all those jar files in the lib folder of java home directory.
> Using this method you need to use the classpath. Java will
> automatically detect it. If you are using any Java Extension framework
> component then put the jar file in <java_home>/lib/ext directory.

I personally won't do this... I am 100% certain I'll forget which JAR is for
which application, and even get the versions wrong. I don't like polluting
my folders... I'm very computer-tidy. :-)


> 2) The second option is little bit un-reliable but you can use this
> with a little sense. Make a single jar file of all those 22 jar files
> and include that single jar file in your classpath. But make sure that
> the folders of the each jar file must not be same.

You would need to extract all the JAR files and re-archive them inside a
single JAR. This also cannot handle different versions of the same class, or
classes with identical names.


I'd recommend using a script to renew the CLASSPATH environment variable. Do
it on a app-by-app or project-by-project basis.


 
 
Paul Lutus





PostPosted: 2004-9-1 23:51:00 Top

java-programmer >> Including a folder's JAR files in CLASSPATH KC Wong wrote:

/ ...

> You would need to extract all the JAR files and re-archive them inside a
> single JAR. This also cannot handle different versions of the same class,
> or classes with identical names.

Unless the jar file contains distinct packages, which is recommended in any
case.

> I'd recommend using a script to renew the CLASSPATH environment variable.

VBI. Instead, I would recommend passing a classpath argument on the java
command-line. This is much more appropriate.

--
Paul Lutus
http://www.arachnoid.com