This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting up Classpath

 
Sulbha Jan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I am trying to setup my classpath for my jar file
I set up my classpath in the following way
.;c:\dir\file.jar
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?
Thanks
[ October 26, 2005: Message edited by: Sulbha Jan ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javaranch has a useful HOW TO here which might help.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This picks up from there and gets into trickier packages & such. Let us know how you work this out!
 
Sulbha Jan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic