View RSS Feed

My Java Tips

Path vs ClassPath

Rate this Entry
by , 11-07-2011 at 06:47 PM (482 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:

echo %PATH%

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\, then your PATH and CLASSPATH should be set to:


I hope this helps.

Submit "Path vs ClassPath" to Facebook Submit "Path vs ClassPath" to Digg Submit "Path vs ClassPath" to Submit "Path vs ClassPath" to StumbleUpon Submit "Path vs ClassPath" to Google

Tags: None Add / Edit Tags
Java SE