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

How to set class path or whatever it is

 
Mradul Jain
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
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?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or read the faq.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic