File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Setting Library On Jars In Classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Setting Library On Jars In Classpath" Watch "Setting Library On Jars In Classpath" New topic
Author

Setting Library On Jars In Classpath

Vikas Aggarwal
Ranch Hand

Joined: Jun 22, 2001
Posts: 140
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.
Rodney Woodruff
Ranch Hand

Joined: Dec 04, 2001
Posts: 80
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


Hope This Helps
Vikas Aggarwal
Ranch Hand

Joined: Jun 22, 2001
Posts: 140
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?
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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
 
 
subject: Setting Library On Jars In Classpath
 
Threads others viewed
Package at multiple locations
Jars within Jar
New Java, old CORBA
EARs, WARs, classpaths, and manifests
JAR Files and Class Path
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com