folks,
can CLASSPATH be set to point to
a) a directory containing bunch of .jar files OR
b) each individual .jar file in the directory
in my testing a) above did NOT work but having to
include each individual .jar in CLASSPATH as in b) above
is painful.
any insight or pointers to a faq addressing this are highly
appreciated.
thanks,
-badari
send2r@gmail.com - 20 Feb 2006 19:05 GMT
You can not just point CLASSPATH to a directory and expect to load
classes from all "*.jar" s lying there.
If you point your CLASSPATH to a directory, only *.class -es in that
directory will be loaded from that path.
If you are too irritated by this is or think that the tools that help
you in such situations(ant script/shell scripts) are not good enough -
you can try the following:
Extract all your classes out of *.jars and keep under some common
folder( say, $HOME/java/lib) preserving their directory structure.
Now if you point to this directory($HOME/java/lib) in CLASSPATH all
your library classes will be picked up- this is a work around but not a
rare one.
HTH
RC
> folks,
>
[quoted text clipped - 11 lines]
> thanks,
> -badari
Jean-Francois Briere - 20 Feb 2006 23:07 GMT
Using ANT might help you a lot with setting the class path with a bunch
of .jar files from folder(s). For instance :
<classpath>
<fileset dir="someJarFolder">
<include name="**/*.jar" />
</fileset>
<fileset dir="someOtherJarFolder">
<include name="**/*.jar" />
</fileset>
</classpath>
You could also simply use a script that sets the CLASSPATH environment
variable with all the zips/jars inside a(many) folder(s).
On Windows NT/2000/XP/2003, I allways use this _setcp.bat script in
this way :
> call _setcp.bat "someJarFolder" "someOtherJarFolder"
Where _setcp.bat goes like this:
-----------------------------------------------------------------------------------------------------------------------
@echo off
set CLASSPATH=.
call :setall %*
goto end
:setall
if .%1.==.. goto end
set dir=%1
set dir=%dir:"=%
set CLASSPATH=%CLASSPATH%;%dir%
for %%i in ("%dir%\*.jar") do call :setone "%%i"
for %%i in ("%dir%\*.zip") do call :setone "%%i"
shift
goto setall
:setone
set file=%1
set file=%file:"=%
set CLASSPATH=%CLASSPATH%;%file%
:end
-----------------------------------------------------------------------------------------------------------------------
You could do the same on Unices
Regards