• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Classpath

 
adam faith
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
adam faith
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, its starting to make sense since i posted the question and experimented
 
Frank Carver
Sheriff
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
adam faith
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i have never been on TV, what sort of proof do i have to give
 
Frank Carver
Sheriff
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic