Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Beginning Java and the fly likes How to set class path or whatever it is Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to set class path or whatever it is" Watch "How to set class path or whatever it is" New topic

How to set class path or whatever it is

Mradul Jain

Joined: Feb 22, 2010
Posts: 2
I ve just started with java and I m using jdk1.6.
While programming what I do is keep the java files in the bin directory(i.e. not a pretty good habit), so when i need to compile the prg, I just type the javac command followed by my class name; for that i first need to use the cd command to go to"C:\java...".

How can I avoid to go to bin for using java commands?
I ve heard that setting of sm classpath and smthing is required for that. How to do that?

My (extension) name is exe and I am not a VIRUS
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Welcome to Javaranch
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Or read the faq.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
marc weber

Joined: Aug 31, 2004
Posts: 11343

Understand that the PATH and the CLASSPATH are two entirely different things.

When people resort to putting their own files in the Java bin directory, it's usually because they did not update their PATH variable when they installed Java, and this is the only way they've found to get files to compile. Updating your PATH will allow your system to find these Java tools regardless of what directly you're compiling from. See the link provided by Seetharaman for instructions on updating your PATH.

It's best to avoid setting a system CLASSPATH at all. (But if you do need a CLASSPATH, be certain it includes a dot (.) indicating the current directory.)

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
I agree. Here's the link:
subject: How to set class path or whatever it is
It's not a secret anymore!