# path vs classpath

Rinku Gambhir
Greenhorn
Posts: 8
To run a simple program we need to set the path in environment variables
we may specify it in path or classpath variable,

what is the difference between the two

i.e path C:\Program Files\Java\jdk1.5.0_06\bin;
and classpath C:\Program Files\Java\jdk1.5.0_06\bin;

And also in Environment varibale we have User variables and System variables, what is the difference between the two.

Christophe Verré
Sheriff
Posts: 14691
16
The PATH variable contains directories where binary files (e.g. EXE files in Windows) will be looked for.
If you open a command prompt and type "javac", you're supposed to have the "bin" directory of your sdk into the PATH, otherwise you'll get an infamous "Command not found" error message.

The CLASSPATH contains directories (or JAR files), from where your java compiler/runtime will look for .class files (and some others).
For example, "java Hello.class" will not work unless you set the directory (or JAR file) Hello.class is in, into your CLASSPATH.

Barry Gaunt
Ranch Hand
Posts: 7729
Just to add - it is unusual to have a "bin" directory in your CLASSPATH, usually it would contain directories like "lib", "jar"...