• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting Library On Jars In Classpath

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a directory named lib in C drive like c:\lib. It has near about 100 jar files. Now I want them to get into classpath without specifying each and every jar name.
I tried like
SET CLASSPATH=C:\lib;%CLASSPATH%
but none of the jars get into the classpath. My programs give errors (ClassNotFoundException) for the classes which are present in the jars though I am importing them correctly. For example in c:\lib there is jar in which the files are under package com.sgn.MyContext, then I am importing it like import com.sgn.MyContext.*;
Trying to access any of the classes under this package gives ClassNotFoundException.
Please help. It is very urgent.
Thanks.
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest creating a batch file that contains the command necessary for executing your application. This way you only have to type the names of the 100 jars once and can easily add and remove jars as you wish.
Then at the command line you just have to type: YourCommand.bat and your application will run.
-- Rodney
 
Vikas Aggarwal
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your suggestion. I have also tried that and the files compile successfully but at run time it doesn't help. I need to have all the jars in my classpath at run time. In other words I will have to specify them in autoexec.bat(win98) or in environment variable' classpath(winNT).
I tried to do c:\lib\*.jar in the autoexec.bat. It doesn't help. Any suggestions?
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have a copy of Apache Ant? If not, do download it; for its own sake as much as for what follows.
In jakarta-ant-*/bin/, observe how the ant.bat file uses a for loop calling lcp.bat to build a CLASSPATH containing all the jars in lib/. Recycle the idea with abandon.
- Peter
 
I knew I would regret that burrito. But this tiny ad has never caused regrets:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic