Path vs ClassPath
by, 11-07-2011 at 06:47 PM (553 Views)
I have found may people asking the difference between ClassPath and path. They tend to mix these and find this confusing. I will address this issue in this post.
Path is simply a system wide variable that tells where to find your commands. Like you can run directory command (dir) from an path. This is so because Windows path is set in the path variable. To see the contents of path variable, use following command on command prompt:
Now lets talk about Classpath. It is Environment Variable that tells JVM or Java Tools where to find your classes. You may include different useful packages in the classpath for easy referencing. To view the contents of the classpath, use following command on command prompt:
Assume that Java is installed in C:\jdk1.5.0\ and your code is in C:\Test\example.java, then your PATH and CLASSPATH should be set to:
I hope this helps.