This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes how to set class path? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to set class path?" Watch "how to set class path?" New topic
Author

how to set class path?

krishna balaji
Ranch Hand

Joined: Mar 16, 2006
Posts: 31
i included a jar file in my project and i m required to mention jar file location each time i compile and run the code how to set class path in advance ?
<code>
javac -cp location/myjarfilename.jar;. myclass.java
java -cp location/myjarfile.java;. myclass
<code>

this is wat i m doin i want to set class path and do like
<code>
java -cp myjarfile.jar;. myclass.java
java -cp myjarfile.jar;. myclass
<code>
how to set class path before compiling and running?like we set path to jdk
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37953
    
  22
Like we set path to jdk.

Yes, that is exactly how you do it. Probably a bad idea to set the classpath permanently, but if you want to do it, do exactly what you do for setting path, but click the classpath environment variable instead.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37953
    
  22
There is another post about setting classpath here. It has more useful discussion about classpaths, which I think would be helpful for you.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to set class path?
 
Similar Threads
Including a jar within a jar
chapter 10 question
basic Q.
Question about java and javac commands
Help