This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Get Programming with Java (MEAP only) and have Peggy Fisher on-line!
See this thread for details.
Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

put directory in classpath  RSS feed

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a directory that contains a lot of jar file. Is it possible to put the directory in the classpath, instead of putting the jar file one by one?
Susilo
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
no. there is no way to just put the directory in the classpath.
u can probably write a loop in the script (.bat on windows and shell script on unix/linux) to do that for u...
i usually write following loop to include every jar file in the classpath
for i in `ls $HOME/jars/*.jar`
do
CLASSPATH=$CLASSPATH:$i
done
export CLASSPATH
javac *.java
this is assuming unix/linux and bash shell on it. somebody can provide the script on windows as well...
same way u can include .zip files if there are...
regards
maulin
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
It can be done but typically "- insert anti - Microsoft comment here -".
This will work on Windows 2000 machines. I have not tested it on anything else but I would imagine it should work on XP too.
First you need to make sure that Command Extensions and Delayed Expansion are enabled in your command shell. To do this make sure that the
following entries in your system registry (use REGEDT32 to check) are present and enabled (set to value 0x1).
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\DelayedExpansion
and
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions
(You can also use a switch when running CMD.EXE to do this "CMD /E:oN /V:oN").
Once this is done the following script will do the same as the linux/unix script.
FOR %%I IN (*.jar) DO (
SET CLASSPATH=!CLASSPATH!%%~fI;
)
Hope this helps.
[ edited to disable the smilies -ds ]
[ June 21, 2003: Message edited by: Dirk Schreckmann ]
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for answering Susilo's question, Malcolm.
As part of my moderator duties, I have to request you to change your name according to JavaRanch's Naming Policy. In your case you have to add a lastname.
Thanks
-Barry
 
Susilo Saja
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys, that really helps
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!