Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

classpath to a directory?

Thread view: 
badarisj@gmail.com - 20 Feb 2006 18:01 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.