File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Setting up Classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Setting up Classpath" Watch "Setting up Classpath" New topic

Setting up Classpath

Sulbha Jan
Ranch Hand

Joined: Jan 02, 2005
Posts: 37
Hello All,
I am trying to setup my classpath for my jar file
I set up my classpath in the following way
But somehow the path is still not established because
when i compile my java program it gives me an error message of
package not found (The class I am using is one of the class defined in that jar file)

But if I specify my classpath while compiling my java program on DOS prompt using javac then it compiles it successfully.
While running my java program (using command java on DOS prompt),again I have to specify the classpath for file.jar, only then the programs runs.
Could anyone please tell where am I going wrong?
On the command prompt I typed echo %classpath% but it does not show
the classspath but instead gives the text %classpath% which I guess it means classpath is not set
Can you explain why? and what is the solution for this.
I also tried setting my user environment variable and giving the value as the path for file.jar, even that didnt work.
Please Please can anyone tell where am i going wrong?
[ October 26, 2005: Message edited by: Sulbha Jan ]
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Javaranch has a useful HOW TO here which might help.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
This picks up from there and gets into trickier packages & such. Let us know how you work this out!

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Sulbha Jan
Ranch Hand

Joined: Jan 02, 2005
Posts: 37
Thank you! Thank you! to Paul Sturrock and Stan James
It worked. The mistake I was doing was, I was not naming the user environment variable as CLASSPATH..
I agree. Here's the link:
subject: Setting up Classpath
It's not a secret anymore!