aspose file tools*
The moose likes Beginning Java and the fly likes JAR Files and CLASSPATH  Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JAR Files and CLASSPATH  Problem" Watch "JAR Files and CLASSPATH  Problem" New topic
Author

JAR Files and CLASSPATH Problem

Aniah Ushie
Greenhorn

Joined: Feb 17, 2006
Posts: 1
Howdy fellas! I'm working on a project that requires me use some API's (which are zipped Jar files). The vendors gave their instructions:
(a) Unzip the Zip file (I ravished that with Winzip)
*(b) The resulting (unzipped) directory has 3 directories among which is the lib directory, add all the .jar in the lib directory to ur Classpath. I did so thru the Enviroment Variable in Windows.

The problem now is that the example code which I am supposed to test doesnt compile. It imports some packages and classes which I can only see if I extract the Jars (ie jar xf jarFile). These imported classes and packages and their member functions are what javac complains about. I believe there's something I'm not doing right. I'll need someone to give me a detailed approach to using jar files in a program, thanks.
Pratik Lohia
Ranch Hand

Joined: May 05, 2005
Posts: 88
How did you add it to the classpath using envirinment variables?
1. Specified each jar seperately OR
2. Just added the path upto the lib directory?

The second method would be the more appropriate way to do. But watever you do remember to append the ";" to the end of the path, otherwise the CLASSPATH will not pick up the last path mentioned.

Hope that helps!!!
Chandra Sagi
Ranch Hand

Joined: May 05, 2005
Posts: 162
But watever you do remember to append the ";" to the end of the path, otherwise the CLASSPATH will not pick up the last path mentioned.
--------------------------

Are you sure this is correct. Different jar files should be separated by a ";" but I think it is not required for the last one. Try to add your present directory to the CLASSPATH too. like set CLASSPATH=%CLASSPATH%;.\

The best method I think would be to create a CLASSPATH variable in the Environment variables and add .jar files to it. check to see whether they are in the classpath from the command prompt by typing "set classpath". When you add something include %CLASSPATH% so that earlier set classpath would still exist. One other way would be to have a small batch script which would set your classpath as required for your application. You can run it when its required instead of setting it in Environmental variables.

Hope this makes sense to you.

Cheers
Chandu
----------
SCJP 1.4
SCWCD(preparing)
adithya kallu
Greenhorn

Joined: Nov 01, 2005
Posts: 23
i think even simpler would be take all the jar files and put it in web-inf/lib
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9052
    
  12
Originally posted by Pratik Lohia:
How did you add it to the classpath using envirinment variables?
2. Just added the path upto the lib directory?

The second method would be the more appropriate way to do.

I think this won't work. As far as I know, you still need to add each individual jar file to your classpath.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61652
    
  67

Moved to Java in General (beginner).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAR Files and CLASSPATH Problem