aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes path vs classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "path vs classpath" Watch "path vs classpath" New topic
Author

path vs classpath

Gaurav
Greenhorn

Joined: Apr 17, 2007
Posts: 5
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

Joined: Nov 24, 2005
Posts: 14672
    
  11

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.


[My Blog]
All roads lead to JavaRanch
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Just to add - it is unusual to have a "bin" directory in your CLASSPATH, usually it would contain directories like "lib", "jar"...


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: path vs classpath
 
Similar Threads
class path
Setting up JAVA
how to find Java Server VM
java on command
question on package and classpath