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 Classpath 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 "Classpath" Watch "Classpath" New topic
Author

Classpath

adam faith
Greenhorn

Joined: Aug 24, 2002
Posts: 22
Hi,
Sorry to be a nuisance, but i am new to programming and java. Can somebody tell me exactly what the classpath is for?
Many Thanks and sorry for the silly question.
Cheers
Adam
Preety Narashimhan
Greenhorn

Joined: Aug 19, 2002
Posts: 28
Basically the classpath is used for the Java compiler to search for the source files (.java) in the path/rootpath mentioned in the classpath variable.
adam faith
Greenhorn

Joined: Aug 24, 2002
Posts: 22
Thanks Pretty,
My next silly question is then, if i have multiple folders for src files, does that mean i have to have a seperate classpath for each one so the compiler knows where to look?
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
adamfaith
Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!


Dave
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Basically the classpath is used for the Java compiler to search for the source files (.java) in the path/rootpath mentioned in the classpath variable.

Preety is almost correct. The classpath is used by the jvm (the java command) to search for the *.class files it needs to run the app.

The source files can be whereever you want them to be. When you compile them using javac (which needs to be in your path), by default the *.class files (the compiled files) go in the same directory. In this case, yes, you would need to have each source path in your classpath (or change your classpath each time).

I suggest that you always put your *.class files into the same subdirectory (maybe named "classes") to keep things simple, at least to begin with. Once you're up and running you can play around with the different switches that come with the "java" and the "javac" commands.
[ August 24, 2002: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
adam faith
Greenhorn

Joined: Aug 24, 2002
Posts: 22
thanks, its starting to make sense since i posted the question and experimented
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Are you the Adam Faith? If so I think you played me in a TV series!
If not, can you give us some sort of proof that this is your real name? Although we don't invoke it often, we do have a rule of no "borrowing" the names of celebrities.
Thanks.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
adam faith
Greenhorn

Joined: Aug 24, 2002
Posts: 22
no i have never been on TV, what sort of proof do i have to give
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I dunno really, it's never cropped up so far. Every case of someone using a "famous" handle here has turned out to be someone just pretending.
I'm willing to let it go if you assure me it is your real name, and none of the other Sheriffs seem worried. I'll ask and get back to you.
I'm sorry if you are offended, by the way. It's just that every few months or so we have some sort of "silly name" outbreak, and policy is to keep an eye on it.
For the "Adam Faith" and "Frank Carver" connection, see: http://www.vh1.com/artists/az/faith_adam/bio.jhtml http://epguides.com/LoveHurts/ and so on.
adam faith
Greenhorn

Joined: Aug 24, 2002
Posts: 22
Its Okay i am not offeneded, but it really is my name. I didnt even know there was somebody famous -who had the same name.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I've had a word with some of the other Sheriffs, and it seems that they'd never heard of Adam Faith (the singer and actor) either. Still, at least you can claim to be famous at parties, now
If by chance anyone does happen to bother you about this later, refer them to me. Sorry for the trouble.
Meanwhile, have you got the hang of classpaths yet, or are there still any areas which puzzle you?
adam faith
Greenhorn

Joined: Aug 24, 2002
Posts: 22
Thanks for the tip, but i dont think anybody will be impressed as they probably havnt heard of the famous adam - wont stop me trying tough
Yes i found the replies very helpfull for classpaths - basically it tells the compiler where to find the .class files (correct?). I have added it to my path and dont have any problems with it.
Cheers,
Adam Faith (not the famous one)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Classpath
 
Similar Threads
MySQL db - migrating from Access (but where is the driver?!)
need help when compile the code
CLASSPATH setting problem
Compile problem
EJBQL COnnection problem with Ireport 3.6